Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 09-13-2001, 01:25 PM   #1
Registered: Sep 2001
Location: Gaithersbury, Maryland
Distribution: RedHat 7.1
Posts: 3

Rep: Reputation: 0
How to remove directories?


I am new to linux and have the following questions on how to delete directories. I copied a file that contains multiple directories from a floppy to a directory under /root . Now I am trying to delete the entire file. What command should I use? I don't think I have to empty each subdirectories and then delete every of them one by one with 'rmdir', but I don't know any other way to do it.

Some times even all the files in a directory apparently have been deleted ('ls -l' gives 0 file), when trying to remove the directory itself with 'rmdir', I still get the message " directory is not empty", thereby the directory can't be deleted. Why does this happen, how to deal with it?

I appreciate greatly if anyone could answer above questions.


Old 09-13-2001, 02:42 PM   #2
LQ Newbie
Registered: Feb 2001
Location: Eastern IL Univ, Charleston, IL
Posts: 11

Rep: Reputation: 0
First, it is usually a good idea to create a regular user account and work with that regular user account on a day-to-day basis. This will prevent you from doing something that you will SERIOUSLY regret

Next, if you want to recursively delete a directory structure, type rm -rf <directory> .

BEFORE YOU DO THIS, type pwd and ls to make sure that (a) you are in the directory you want to be in and (b) that the directory that you are wanting to delete is there. The reason for this is that rm -rf executed as root WILL ERASE IMPORTANT FILES IF YOU ARE NOT CAREFUL. (i.e., if executed from the / directory, will delete all files on linux system).

If the directory listing done under a regular 'ls -l' shows no files, try doing an ls -ld .* (shows all the dot files under that structure w/o listing the directory above you) .

Check out the UNIX command reference on TechRepublic - I'm not sure what the link is, but it lists several frequently-used commands for UNIX and LINUX.

Old 09-13-2001, 03:54 PM   #3
Senior Member
Registered: May 2001
Location: Bristol, UK
Distribution: Slackware, Fedora, RHES
Posts: 2,243

Rep: Reputation: 46

Originally posted by sbscomp
rm -rf <directory>
Even a fully trained Jedi should be wary of such power


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
Remove directories recursively with same name cboyd Linux - Newbie 5 01-14-2007 10:48 PM
Searching multiple directories and sub directories for a file jeep99899 Linux - Newbie 2 10-13-2005 01:23 PM
Remove directory and sub directories newuser455 Linux - Newbie 5 06-01-2005 01:31 AM
remove save file, many directories jamaas Linux - Newbie 1 08-23-2004 06:01 AM
how do I remove all empty directories? noisybastard Linux - General 2 08-11-2003 12:47 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:17 PM.

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