LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   rm -rf/ (https://www.linuxquestions.org/questions/linux-newbie-8/rm-rf-945574/)

Tombuntu 05-17-2012 01:43 PM

rm -rf/
 
Hi, can someone please tell me what this does, rm -rf/? When I try it in Ubuntu I get an illegal option error for the '/'.

Thanks

Tombuntu

Ser Olmy 05-17-2012 01:46 PM

You need a space between "-rf" and "/".

Oh, and it deletes every file you have write permissions on. If run as root, it deletes the entire operating system and all data.

Mr. Alex 05-17-2012 01:55 PM

Quote:

Originally Posted by Ser Olmy (Post 4681128)
and all data.

...on currently mounted partitions.

273 05-17-2012 01:57 PM

I would recommend that you do not run rm -rf /. However, under most modern distributions it will not work. As evidenced by my quick test on a Debian machine.
Code:

root@debian:~# rm -rf /
rm: it is dangerous to operate recursively on `/'
rm: use --no-preserve-root to override this failsafe
root@debian:~#

It used to be a bit of a cruel joke that people in the know told people to type it as the answer to a problem.

Ser Olmy 05-17-2012 02:03 PM

Quote:

Originally Posted by Mr. Alex (Post 4681136)
...on mounted partitions.

You're quite right. The OP should make sure to insert and mount any and all USB sticks and removable hard drives that he owns, before running the command (with sudo).

Mr. Alex 05-17-2012 02:06 PM

https://www.youtube.com/watch?v=D4fzInlyYQo :D

273 05-17-2012 02:11 PM

Quote:

Originally Posted by Mr. Alex (Post 4681146)

Yes, Oct 31, 2007 isn't really "modern" is it? If that is real I am surprised it took them as long as it did to protect against this.

Mr. Alex 05-17-2012 02:13 PM

Quote:

Originally Posted by 273
Yes, Oct 31, 2007 isn't really "modern" is it?

I wasn't posting it against modern protection from "rm -rf /". Just to show what it looks like.

273 05-17-2012 02:22 PM

Quote:

Originally Posted by Mr. Alex (Post 4681151)
I wasn't posting it against modern protection from "rm -rf /". Just to show what it looks like.

Ah, I see. :D

Ser Olmy 05-17-2012 02:29 PM

Quote:

Originally Posted by 273 (Post 4681149)
Yes, Oct 31, 2007 isn't really "modern" is it? If that is real I am surprised it took them as long as it did to protect against this.

I would argue that the "protection" isn't really the right solution to the problem, as you're not supposed to do system administration such as file management as root. And you're not supposed to store important data on systems that aren't backed up properly on a regular basis.

The command line contains a staggering amount of potentially deadly traps for an inexperienced user to fall into. For instance, imagine something as mundane as copying or moving all files in a directory to a different location with cp * ../newdir or mv * ../newdir. Now leave out the "../newdir" part by pressing Enter too soon. Ouch. (In the latter case, probably something slightly stronger.)

Granted, I see few valid uses for a recursive rm in /, but still.

273 05-17-2012 02:35 PM

Quote:

Originally Posted by Ser Olmy (Post 4681155)
I would argue that the "protection" isn't really the right solution to the problem, as you're not supposed to do system administration such as file management as root. And you're not supposed to store important data on systems that aren't backed up properly on a regular basis.

I think it's there because that particular line has pretty much only malicious uses. I agree that protecting commands isn't generally the best way to do things but in this case and especially for a distro like Ubuntu (the one in the video) I think it may be worth it. I know there are other ways to do the same but "rm -rf /" is found posted as an answer to everything and I suspect is in a heck of a lot of shell scripts too.

Roken 05-17-2012 06:42 PM

Is asking the question not against forum rules - the OP has a single post and asking the question is an invitation to try it - I suggest deleting the thread.

pixellany 05-17-2012 06:50 PM

Quote:

Originally Posted by Tombuntu (Post 4681125)
Hi, can someone please tell me what this does, rm -rf/? When I try it in Ubuntu I get an illegal option error for the '/'.

Thanks

Tombuntu

Tom;
Assuming that you are not just trolling us----I'm curious where you got the idea to try this command without knowing what it does.

Serious advice: If you don't know what a command does, then don't enter it........

nixblog 05-18-2012 04:55 AM

Quote:

Originally Posted by 273 (Post 4681138)
I would recommend that you do not run rm -rf /. However, under most modern distributions it will not work. As evidenced by my quick test on a Debian machine.
Code:

root@debian:~# rm -rf /
rm: it is dangerous to operate recursively on `/'
rm: use --no-preserve-root to override this failsafe
root@debian:~#

It used to be a bit of a cruel joke that people in the know told people to type it as the answer to a problem.

Yeah, the --preserve-root option is a safeguard, the --no-preserve-root will override this and delete everything that you have permission to delete. If you do it, you only have yourself to blame...


All times are GMT -5. The time now is 07:51 AM.