How far will you get with “rm -rf /” on Linux ?

Have you ever left your Terminal logged in,  only to find a so called friend/ colleague came up and typed ” rm -rf / ” ?

I actually did so on a virtual machine (VM). It’s a CentOS VM which was used for some applications test. I created a backup of this VM and thought of shooting a video as I proceed to run ” rm -rfv / ” on it.

You can watch my video recordings here.

I also did so to learn what all directories do not get deleted with this command. And also, after the command has executed  will “rm” have removed itself  ? It seems that OS protects certain directories like /sys, /proc, /dev. At the end of the video you can see that “ls” command is not found and so is “/bin/rm”. Needless to say /bin, together with /bin/echo has been deleted. So, issuing ” echo * ”  just displayed * at the promt. I rebooted the VM and ended up with a black screen. OS is gone !! After the command finishes, disk is wiped off, including the OS. The Kernel and current processes will continue to run from memory, but many processes will die because they fail to access some file. OS will obviously fail to boot next time.

Still unanswered – Files that is currently open ( i.e rm ) even if deleted, won’t disappear from disk until closed.  I am not sure, if it is safe to assume,  the Kernel could very well load the removed file into memory and remove it from disk immediately ; and keep this memory copy running until the command is open  (  i.e rm is running )

Mistakenly, do not run this command on host system’s terminal. I did so on a VM, else you will land up putting your head on hand, hand between knees ! as one who’s world has just come to an end.

Advertisements
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: