Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 05-30-2005, 09:11 PM   #1
Registered: Feb 2005
Posts: 65

Rep: Reputation: 16
Removing a Directory from the Terminal without deleting each file or folder

How can I delete a folder without deleting each file or folder via terminal?

So let's say I would want to delete the folder


which has 230 files...

How can I delete the folder from the terminal?

I do not want to be prompted to delete each file or folder, yet, delete the complete folder.

Old 05-30-2005, 09:34 PM   #2
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Jessie 8.4
Posts: 5,867

Rep: Reputation: 345Reputation: 345Reputation: 345Reputation: 345
Su to root, then give this command:

rmdir --ignore-fail-on-non-empty <dirname>

where <dirname> is the name of the directory to remove.

Or, you could try: rm -dR <dirname> (-d works only for the root user).

-d remove the directory even if it isn't empty (root user only)
-R recursive drill down through the directory.

Last edited by bigrigdriver; 05-30-2005 at 09:39 PM.
Old 05-30-2005, 09:37 PM   #3
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Or (slightly shorter)
rm -rf /home/username/test

Old 05-30-2005, 10:47 PM   #4
Registered: Feb 2005
Posts: 65

Original Poster
Rep: Reputation: 16

Thank You. You were all very helpful.

Next time, I'll have to do a man on rmdir. I did not see anything on that, though.

Thanks, once again.
Old 05-30-2005, 11:30 PM   #5
Senior Member
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

Rep: Reputation: 46
Originally posted by Tinkster
Or (slightly shorter)
rm -rf /home/username/test

just adding a little to this, be careful when you are root with rm, for example:

rm -fr / home/username/test

notice the accidental space between / and home (which the shell will interpret as "remove the root directory ( / )), if you accidentally do this, say goodbye to your entire filesystem.


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
switching from a file manager to a terminal and back (with the same directory) Zed Lopez Linux - Software 1 06-08-2005 02:29 AM
"WARNING: Circular directory structure" error when deleting directory pistonbrew Linux - Software 5 02-03-2005 06:05 AM
deleting a shared folder aymbpc Linux - Newbie 3 09-23-2003 06:01 PM
removing/deleting a user cuss Linux - General 7 02-27-2003 02:27 PM
Deleting old kernel and removing it from boot loader? Koolinux Linux - General 4 11-07-2002 06:10 PM

All times are GMT -5. The time now is 12:35 AM.

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