0

I just cd to "/" on a Mac and accidentally entered "rm -R *". I know the command means delete everything in "/" but I wasn't sudoing, should I reinstall Mac OS? Or does a mac protect against this sort of things.

2 Answers 2

7

I don't agree with Yitzchak's answer.

If you run rm -R *, it will recursively delete files you own and have write permissions on. Even if you let the command run for a couple of seconds, it is possible that you deleted some files that you owned. Thus, saying "you're fine" is potentially dangerous. Just check what ls -R * lists. This is what you would've removed. The fact that you left out sudo will not stop the command from executing.

First, you will delete applications you've installed by dragging them to /Applications. They are owned by you. Eventually, the listing will recurse into your home directory under /Users/, which by default is owned by your user too, and not root. This is where probably all of your private files reside.

I would strongly advise you to restore from your backup (you use Time Machine, right?) to a previous point and also check if you miss any important files in your home directory.

If you ran the command without sudo or from a non-root shell, you shouldn't have messed with any system files, so reinstalling OS X shouldn't be necessary. That being said, it can't hurt, because a typical OS X (Snow Leopard, Lion) install will not remove your documents, but repair/reinstall system files.

2
  • 1
    agreed. Remember, you can delete files where you have write access to the directory, which is more than you think. Dec 29, 2011 at 19:20
  • Right you are. My mistake.
    – Yitzchak
    Jan 10, 2012 at 15:57
1

You may have inadvertently removed files to which your user had write permissions to considering you passed the -R switch, depending on how long you let the command recurse.

A re-install shouldn't be necessary as @Yitzchak mentioned as your user should not have sufficient permissions to damage critical system files. That being said, if you do experience any odd-behavior or instability, it may behoove you to re-install.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .