LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-17-2012, 01:43 PM   #1
Tombuntu
LQ Newbie
 
Registered: May 2012
Posts: 1

Rep: Reputation: Disabled
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
 
Old 05-17-2012, 01:46 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,334

Rep: Reputation: Disabled
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.
 
Old 05-17-2012, 01:55 PM   #3
Mr. Alex
Senior Member
 
Registered: May 2010
Distribution: No more Linux. Done with it.
Posts: 1,238

Rep: Reputation: Disabled
Quote:
Originally Posted by Ser Olmy View Post
and all data.
...on currently mounted partitions.

Last edited by Mr. Alex; 05-17-2012 at 02:03 PM.
 
Old 05-17-2012, 01:57 PM   #4
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
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.
 
1 members found this post helpful.
Old 05-17-2012, 02:03 PM   #5
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,334

Rep: Reputation: Disabled
Quote:
Originally Posted by Mr. Alex View Post
...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).
 
Old 05-17-2012, 02:06 PM   #6
Mr. Alex
Senior Member
 
Registered: May 2010
Distribution: No more Linux. Done with it.
Posts: 1,238

Rep: Reputation: Disabled
https://www.youtube.com/watch?v=D4fzInlyYQo
 
Old 05-17-2012, 02:11 PM   #7
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Quote:
Originally Posted by Mr. Alex View Post
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.
 
Old 05-17-2012, 02:13 PM   #8
Mr. Alex
Senior Member
 
Registered: May 2010
Distribution: No more Linux. Done with it.
Posts: 1,238

Rep: Reputation: Disabled
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.
 
Old 05-17-2012, 02:22 PM   #9
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Quote:
Originally Posted by Mr. Alex View Post
I wasn't posting it against modern protection from "rm -rf /". Just to show what it looks like.
Ah, I see.
 
Old 05-17-2012, 02:29 PM   #10
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,334

Rep: Reputation: Disabled
Quote:
Originally Posted by 273 View Post
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.

Last edited by Ser Olmy; 05-17-2012 at 02:30 PM.
 
Old 05-17-2012, 02:35 PM   #11
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Quote:
Originally Posted by Ser Olmy View Post
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.
 
Old 05-17-2012, 06:42 PM   #12
Roken
Member
 
Registered: Oct 2011
Location: Warrington, UK
Distribution: Arch local, Debian on VPS, several RPIs.
Posts: 300
Blog Entries: 1

Rep: Reputation: 55
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.
 
1 members found this post helpful.
Old 05-17-2012, 06:50 PM   #13
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by Tombuntu View Post
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........
 
Old 05-18-2012, 04:55 AM   #14
nixblog
Member
 
Registered: May 2012
Posts: 426

Rep: Reputation: 53
Quote:
Originally Posted by 273 View Post
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...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration