LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 05-30-2005, 09:11 PM   #1
lennysokol
Member
 
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

/home/username/test

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.

Thanks
 
Old 05-30-2005, 09:34 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,772

Rep: Reputation: 309Reputation: 309Reputation: 309Reputation: 309
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
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

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


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

Original Poster
Rep: Reputation: 16
Smile

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
__J
Senior Member
 
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

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


Cheers,
Tink
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.
 
  


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 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 11:49 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration