LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 06-05-2002, 06:07 PM   #1
rythomas
LQ Newbie
 
Registered: Jun 2002
Posts: 4

Rep: Reputation: 0
quick & easy way to rmdir's ???


Does anyone know of a quicker and easier way to remove files and (especially) directories other than just manually going in and rm * within a directory, then later just rmdir * once all is cleared out ???
 
Old 06-05-2002, 06:18 PM   #2
vector
Member
 
Registered: Jan 2002
Location: Corvallis
Distribution: Slackware 10.0
Posts: 48

Rep: Reputation: 15
rm -rf

will clear everything out, without a word of warning.

-r remove the contents of directories recursively
-f ignore nonexistent files, never prompt

This will take care of it.
 
Old 06-05-2002, 06:49 PM   #3
linuxcool
LQ Addict
 
Registered: Jun 2001
Posts: 1,183

Rep: Reputation: 47
Be careful using this command. If you accidently run rm -rf /, it will delete everything.



Quote:
From Rashkae:

Important trick. -rf is a very dangerous switch, escpecially if used as root.. For safety, you should always put the -rf *after* the directory name. Example ' rm /home/here -rf ' [Enter]. God have mercy on your soul if your finger accidentally brushes the Enter key right when you have ' rm -rf / ' typed.

Last edited by linuxcool; 06-05-2002 at 06:53 PM.
 
Old 06-05-2002, 08:13 PM   #4
rythomas
LQ Newbie
 
Registered: Jun 2002
Posts: 4

Original Poster
Rep: Reputation: 0
I guess the main thing is to remove the directories quickly.
I don't believe this applies to rmdir ??

If there were a way to remove a couple dozen+ layered subdirectories, that would really help!!

thanks much
 
Old 06-05-2002, 08:30 PM   #5
Sfin
Member
 
Registered: Apr 2002
Location: Michigan
Distribution: Slackware 8.0
Posts: 197

Rep: Reputation: 30
Well that command stated above will remove subdirectories as well as files.

So lets Say you got a Directory Called Temp, and a Subdirectory called Temp2.

Temp
|__Temp2

rm Temp -rf

will delete the subdirectory Temp2, then the directory Temp.
 
Old 06-05-2002, 10:31 PM   #6
linuxcool
LQ Addict
 
Registered: Jun 2001
Posts: 1,183

Rep: Reputation: 47
rythomas, the rmdir command only removes empty directories.
rm <directory_name> -rf will remove the files, subdirectories, and the directory that holds the all files and subdirectories.

Last edited by linuxcool; 06-05-2002 at 10:32 PM.
 
Old 06-06-2002, 08:03 AM   #7
rythomas
LQ Newbie
 
Registered: Jun 2002
Posts: 4

Original Poster
Rep: Reputation: 0
thank you

Thank you all for your help, I was (and will continue to be) extremely careful, and it worked like a charm.

Thanks again & best wishes!
 
Old 06-06-2002, 09:01 AM   #8
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
use a GUI., such as kde or gnome, the graphical file manager will allow you to delete the files with a 'trash can' like windows or mac is should be easier and safer than rm -rf

Last edited by frieza; 06-06-2002 at 09:03 AM.
 
Old 06-06-2002, 12:14 PM   #9
Rashkae
Member
 
Registered: May 2002
Distribution: Slackware
Posts: 125

Rep: Reputation: 15
mc also works really well. It's a nice treat for those of us who still remember Norton Commander
 
Old 06-06-2002, 08:15 PM   #10
linuxcool
LQ Addict
 
Registered: Jun 2001
Posts: 1,183

Rep: Reputation: 47
You're welcome.
 
Old 06-07-2002, 12:51 AM   #11
bkeating
Member
 
Registered: Mar 2002
Location: San Francisco, CA
Distribution: Open/FreeBSD, Gentoo, SuSE
Posts: 511

Rep: Reputation: 38
definetly practice typing the path before you give rm arguments.

like: rm /home/bkeating/test.jpg -rf

instead of: rm -rf /home/bkeating/test.jpg

It's been brought up before, but im just repeating for the sake of saving you and anyone else reading from a big big 'oops'
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick 'n' easy question! orange400 Linux - General 6 09-09-2004 10:36 PM
quick easy SQL qn cadj Programming 1 08-19-2004 07:15 AM
Accepting Shabang Scripts (Quick & Easy Question, Just Can't Find Answer) overbored Programming 3 03-24-2004 06:41 PM
quick easy question alexr186 Linux - Networking 3 11-02-2003 08:48 AM
2 quick and easy questions Nicksan Linux - General 3 06-30-2003 11:41 PM

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

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