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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
05-17-2012, 01:43 PM
|
#1
|
LQ Newbie
Registered: May 2012
Posts: 1
Rep: 
|
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
|
|
|
05-17-2012, 01:46 PM
|
#2
|
Senior Member
Registered: Jan 2012
Distribution: Slackware
Posts: 3,350
Rep: 
|
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.
|
|
|
05-17-2012, 01:55 PM
|
#3
|
Senior Member
Registered: May 2010
Distribution: No more Linux. Done with it.
Posts: 1,238
Rep: 
|
Quote:
Originally Posted by Ser Olmy
and all data.
|
...on currently mounted partitions.
Last edited by Mr. Alex; 05-17-2012 at 02:03 PM.
|
|
|
05-17-2012, 01:57 PM
|
#4
|
LQ Addict
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,681
|
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.
|
05-17-2012, 02:03 PM
|
#5
|
Senior Member
Registered: Jan 2012
Distribution: Slackware
Posts: 3,350
Rep: 
|
Quote:
Originally Posted by Mr. Alex
...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).
|
|
|
05-17-2012, 02:06 PM
|
#6
|
Senior Member
Registered: May 2010
Distribution: No more Linux. Done with it.
Posts: 1,238
Rep: 
|
|
|
|
05-17-2012, 02:11 PM
|
#7
|
LQ Addict
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,681
|
Quote:
Originally Posted by Mr. Alex
|
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.
|
|
|
05-17-2012, 02:13 PM
|
#8
|
Senior Member
Registered: May 2010
Distribution: No more Linux. Done with it.
Posts: 1,238
Rep: 
|
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.
|
|
|
05-17-2012, 02:22 PM
|
#9
|
LQ Addict
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,681
|
Quote:
Originally Posted by Mr. Alex
I wasn't posting it against modern protection from "rm -rf /". Just to show what it looks like.
|
Ah, I see. 
|
|
|
05-17-2012, 02:29 PM
|
#10
|
Senior Member
Registered: Jan 2012
Distribution: Slackware
Posts: 3,350
Rep: 
|
Quote:
Originally Posted by 273
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.
|
|
|
05-17-2012, 02:35 PM
|
#11
|
LQ Addict
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,681
|
Quote:
Originally Posted by Ser Olmy
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.
|
|
|
05-17-2012, 06:42 PM
|
#12
|
Member
Registered: Oct 2011
Location: Warrington, UK
Distribution: Arch local, Debian on VPS, several RPIs.
Posts: 300
Rep:
|
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.
|
05-17-2012, 06:50 PM
|
#13
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809
|
Quote:
Originally Posted by Tombuntu
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........
|
|
|
05-18-2012, 04:55 AM
|
#14
|
Member
Registered: May 2012
Posts: 426
Rep: 
|
Quote:
Originally Posted by 273
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 12:36 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|