Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Just curious, what happens in OS X Maverick if someone issues sudo rm -rf /?
I heard most modern *nix systems are protected from this epic fail.

share|improve this question
1  
It just asks you for your admin password. ;) –  dwightk Mar 21 at 21:19

2 Answers 2

In the interest of science, a VM died to answer this question:

testrm:~ admin$ sudo rm -rf /

WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.

To proceed, enter your password, or type Ctrl-C to abort.

Password:
rm: /dev/fd/0: Operation not supported
rm: /dev/fd/1: Operation not supported
rm: /dev/fd/2: Operation not supported
rm: /dev/fd/3: Not a directory
rm: /dev/fd/4: Bad file descriptor
rm: /dev/fd: Operation not supported
rm: /dev: Resource busy
rm: /home: Resource busy
rm: /net: Resource busy
rm: /private/var/log: Directory not empty
rm: /private/var/run: Directory not empty
rm: /private/var: Directory not empty
rm: /private: Directory not empty
rm: /System/Library: Directory not empty
rm: /System: Directory not empty
rm: /: Is a directory
testrm:~ admin$ 

Interestingly, it succeeded. Back in the Slackware 2 days, I tried this on Linux and after it deleted the dynamically linked libraries rm was using, it failed.

share|improve this answer
    
Why were you able to get the prompt at the end? Seems like /bin/bash would crash after being deleted. Or was that just not the entire output? –  0942v8653 Mar 22 at 17:06
2  
Anything that is already loaded into memory is still there. Also, any files that a process has open are still on disk, and the space is not reclaimed until after all close them. So, since bash was running, it could still show its prompt, etc. But it would not be able to load any commands, since they are all gone. Similarly, when I tried this from a terminal on the Mac, instead of doing an ssh in, the finder and UI was still there... But any time a program tried to open a file, it would fail. –  Alan Shutko Mar 22 at 17:40

Curiosity killed the cat. Do not, under any circumstances, try this at home. </disclaimer>

There are no protections. The --root-protect option was introduced in GNU rm (on by default).

The rm man page for 10.9 does not mention anything like this. Once you've entered your password, it's all gone. Hope you remembered today is International Backup Day (It's always International Backup Day).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.