posted a script into my Terminal and all files are gone..HELP

Discussion in 'macOS' started by diezbarr, Feb 18, 2011.

  1. diezbarr macrumors newbie

    Joined:
    Feb 18, 2011
    #1
    Hi please help. I was trying to reset my office for mac password to install the business edition and got this code from a site:

    rm -rf ~ /Library/Preferences/Microsoft/Office 2008/Microsoft Office 2008 Settings.plist
    rm -rf ~ /Applications/Microsoft Office 2008/Office/OfficePID.plist

    I pasted it into my terminal window and it reset all of my mac.
    I'm running a mac book 5.1 OS X 10.5.8

    Any insight would be greatly appreciated
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    The problem is the space between ~ and the rest. The ~ represents your home directory so you deleted your entire home directory. Unless you have backups, you have nothing.
     
  3. diezbarr thread starter macrumors newbie

    Joined:
    Feb 18, 2011
    #3
    Can I do anything about it?
     
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    The command deleted your files. The only options are restoring from a backup, or attempting to use a file recovery program like Data Rescue.
     
  5. diezbarr thread starter macrumors newbie

    Joined:
    Feb 18, 2011
    #5
    Thank you. Will try that.
     
  6. iThinkergoiMac, Feb 18, 2011
    Last edited: Feb 18, 2011

    iThinkergoiMac macrumors 68030

    Joined:
    Jan 20, 2010
    Location:
    Terra
    #6
    This is why one should be super careful with using the rm command, especially with the -rf modifier. r = recursive, deletes directories. f = forced, will not confirm for delete of files with certain permissions. Especially when all you're doing is deleting two specific files, you're better off navigating to those files in the user interface than using the Terminal if you're unfamiliar with it.

    Upon further thought, there's no reason for the -rf modifier to be there at all!
    Code:
    rm ~/Library/Preferences/Microsoft/Office 2008/Microsoft Office 2008 Settings.plist
    would have worked just as well as
    Code:
    rm -rf ~/Library/Preferences/Microsoft/Office 2008/Microsoft Office 2008 Settings.plist
    I think this may have been malicious and intentional. I hate to point fingers, but I can't imagine any other reason the -rf modifier was there. The rm command has no need to be recursive when deleting single files, which is what you were trying to do.
     
  7. calderone macrumors 68040

    calderone

    Joined:
    Aug 28, 2009
    Location:
    Seattle
    #7
    I doubt it was malicious. Many people don't really know what they are doing. They find a way to delete a file and they stick with it. They never explore the options of if they are unnecessary. Then they decide to toss a "tip" onto their blog and we get results like this.

    That may be why the "-rf" was included, they simply didn't know better.

    That said. You are slightly incorrect in saying that the recursive isn't necessary for single files. Consider .apps, it is a "single file" at first look but is actually a directory. Meaning to delete -r would be necessary.

    To summarize: This is why you should never blindly paste in a command from a website and execute it.
     
  8. LPZ macrumors 65816

    Joined:
    Jul 11, 2006
    #8
    Since the spaces were not escaped, neither statement would work. So your statement is true, but not in the way you intended. :)

    (Your real point about not needing the -rf here is a good one.)
     
  9. Hal Itosis macrumors 6502a

    Hal Itosis

    Joined:
    Feb 20, 2010
    #9
    Google indicates that that pair of commands generally relates to removing license keys from (and/or changing CD keys on) Office 2008 for Mac... most likely for the purpose of allowing multiple versions to run on a network.

    The culprit page (or one of them at least) appears to be here:
    http://en.kioskea.net/faq/6028-office-mac-2008-unable-to-use-another-product-key


    UNbelievable.
     
  10. iThinkergoiMac macrumors 68030

    Joined:
    Jan 20, 2010
    Location:
    Terra
    #10
    You're quite correct, though I was assuming that .apps would be included in needing the -r modifier. It is, of course, not immediately apparent if one isn't familiar with how applications are set up.

    If you're referring to the space between the ~ and the rest of the directory path, I did actually delete that space, it just looks like it's there because of the font. If not, I'm not sure exactly what you're referring to.
     
  11. Hal Itosis macrumors 6502a

    Hal Itosis

    Joined:
    Feb 20, 2010
    #11
    He's referring to the many spaces you didn't escape. For example, the first command you posted attempts to delete the following five items:

    ~/Library/Preferences/Microsoft/Office
    2008/Microsoft
    Office
    2008
    Settings.plist​

    ...which will fail most likely.
     
  12. diezbarr thread starter macrumors newbie

    Joined:
    Feb 18, 2011
    #12
    Thank you for your support. I recovered the data through Data rescue and now have the files back :)
    Any suggestions as to how I can integrate them back into my system. Right now they're in folders and I'm trying to import back but not sure what to do for things like preferences etc.
    Thanks
     
  13. calderone macrumors 68040

    calderone

    Joined:
    Aug 28, 2009
    Location:
    Seattle
    #13
    I didn't even pay attention to the new commands iThinkergoiMac wrote. That is an epic fail.
     
  14. iThinkergoiMac macrumors 68030

    Joined:
    Jan 20, 2010
    Location:
    Terra
    #14
    Oh! Hahahaha... all I did was copy the commands posted in the first post and remove the space between the ~ and the rest of the directory... I didn't even think about the rest of the directory! Man, I can't believe I missed those! :eek:
     

Share This Page