LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-12-2012, 07:16 AM   #1
Jalfor
LQ Newbie
 
Registered: Oct 2011
Distribution: Linux Mint 13 (Cinnamon)
Posts: 9

Rep: Reputation: Disabled
rm -rf vs rm -r


Just a simple question which I can't work out. Why, when people are deleting folders, do people always do it using rm -rf? I have done a few tests and rm -r always does it perfectly well.

According to rm --help, the 'f' option makes rm "ignore nonexistent files, never prompt". I assume by "nonexistent" it is referring to '.' and "..", but these seem to be removed automatically by rm -r.

Thanks for any information. I'm just curious.

Last edited by Jalfor; 07-12-2012 at 07:36 AM.
 
Old 07-12-2012, 07:24 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
There are some distributions that even ask you if your sure to remove a directory also the -r option is given. Namely redhat and centos. Dunno of any other distro though.
 
1 members found this post helpful.
Old 07-12-2012, 07:30 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
'rm -r' works in Debian based OS like Mint and Ubuntu.
Works too in Slackware.

In RHEL, CentOS, Mandriva, PCLinuxOS you will have to say 'yes'
for every single file in a folder, if 'rm -r' is used.
Hence 'rm -rf'.


.

Last edited by knudfl; 07-12-2012 at 07:32 AM.
 
1 members found this post helpful.
Old 07-12-2012, 07:34 AM   #4
Jalfor
LQ Newbie
 
Registered: Oct 2011
Distribution: Linux Mint 13 (Cinnamon)
Posts: 9

Original Poster
Rep: Reputation: Disabled
Ah, makes sense now. Thanks
 
Old 07-14-2012, 11:11 AM   #5
linuxcoder
LQ Newbie
 
Registered: Jul 2012
Posts: 9

Rep: Reputation: Disabled
Quote:
Originally Posted by knudfl View Post
In RHEL, CentOS, Mandriva, PCLinuxOS you will have to say 'yes'
for every single file in a folder, if 'rm -r' is used.
Hence 'rm -rf'..
Is that because it's part of the system as a default or is it because "rm" gets aliased to "rm -i". I've seen a good number of systems that either do the alias trick or have rm move the file(s) to a .trash folder. Getting around either is fairly straightforward. Personally, I hate people having to rely on such tricks as it gives a false sense of security when they happen to be on a system that doesn't offer those same safeguards.
 
Old 07-16-2012, 02:36 AM   #6
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Checked it on Centos-6.3. There is an alias for rm to rm -i like you sad. And I totaly agree with you on the false sense.
Just for me to be sure I always first do a ls ./your_files_to*_delete and if the output only consists of files that I am sure about I arrow-up inside the history, ctrl-a to start of line, ctrl-d to erase ls and type rm. This makes sure one knows what gets deleted.
 
  


Reply



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 On
HTML code is Off



LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:08 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