LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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

Reply
 
Search this Thread
Old 06-05-2004, 06:40 PM   #1
aaronruss
Member
 
Registered: Mar 2004
Posts: 90

Rep: Reputation: 15
How do you remove a non empty directory


I would like to know how to remove a non empty directory. I am trying to use the command rmdir but the directory is not empty and it will not delete.

I want to know how to do this from the command line and do not want to have to go and delete all the folders and files in the directory I just want to remove it all at once.

I have checked the man rmdir, info rmdir and the rmdir --help I can not find any thing that explains how to do this.
 
Old 06-05-2004, 06:42 PM   #2
leonscape
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Debian SID / KDE 3.5
Posts: 2,313

Rep: Reputation: 47
rm -r thedirectory
 
Old 06-05-2004, 08:23 PM   #3
marghorp
Senior Member
 
Registered: Jan 2004
Location: Slovenia
Distribution: Slackware 10.1, SLAX to the MAX :)
Posts: 1,040

Rep: Reputation: 45
or rm -rf directory

the -f option is force, which means it will not prompt you for deleting any of the files in the directory. If you delete without force, you will be prompted for every file in that directory. The -r option is recursively, which means that all files in that directory and its subdirectories will be deleted. So be careful with the rm -rf command.

For example:

The command rm -rf / would be equivalent to format c: in windows and even worse. It would be like a windows command format c: and format d: and format e: and format f: ..... all combined. The rm -rf / actually erases everything on your harddisk or your harddisks.

SO BE CAREFUL!!

However this caution is intended only if you run as root or you have messed your permissions. Running rm -rf / as an ordinary user in a healthy system would result in error messages stating that a user has no permission for deleting /

As every other thing you do as root, is to be very careful.

Peace!

Last edited by marghorp; 06-05-2004 at 08:26 PM.
 
Old 06-05-2004, 08:26 PM   #4
Systematic
Member
 
Registered: May 2004
Location: Mechanicsburg, PA
Distribution: Mainly Slackware, but test run various different distros.
Posts: 77

Rep: Reputation: 15
i use rm -rdf this way its recursive, forces and removes the dir completely..
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
rm: cannot remove directory `ff': Directory not empty blancs Linux - General 17 08-29-2011 01:47 PM
remove a non empty directory in shell acidjuice Slackware 10 06-28-2011 12:02 PM
RMDIR - how to remove a non-empty directory?? jacksmash Linux - Newbie 15 11-23-2003 12:51 PM
How to remove a non-empty dictory? Xiangbuilder Linux - Newbie 6 09-03-2003 03:40 PM
how do I remove all empty directories? noisybastard Linux - General 2 08-10-2003 11:47 PM


All times are GMT -5. The time now is 10:54 AM.

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