Remove / Delete a Directory Linux Command
-
Delete / Remove a Directory Linux Command
Q. I am new to Linux and command line. How do I delete or remove a directory?
A. Use rmdir command. This command remove the DIRECTORY(ies), if they are empty. For example, type the following command to remove /tmp/docs directory:
$ rmdir /tmp/docs
If directory is not empty you will get an error:
$ rmdir letters
Output:rmdir: letters: Directory not empty
You can change directory to find out files:
$ cd letters
$ lsLinux remove entire directory
To remove all directories and subdirectories use rm command. For example remove letters and all subdirectories and files inside this directory, type the following command:
$ rm -rf letters/
53 Comments
Leave a Comment


July 14th, 2009 at 10:20 pm
System administration command. Restore backed up files from a dump archive. Execute this command with one of the following flags.
September 4th, 2009 at 12:27 am
In your bashrc or what ever other shell you are using, you can set up the length of your history – I think it defaults to about a thousand lines.
October 6th, 2009 at 7:30 pm
Like the shell command, list files in the current working directory, or the specified file or directory name. A * before a name indicates items marked for extraction. In verbose mode, the listing will include each item’s inode.
October 18th, 2009 at 3:27 pm
There’s a lot of information here. I’ll be back again.
October 18th, 2009 at 8:57 pm
Valuable thoughts and advices. I read your topic with great interest.
October 19th, 2009 at 7:36 pm
I really like your blog and i respect your work. I’ll be a frequent visitor.
October 22nd, 2009 at 4:58 am
In truth, immediately i didn’t understand the essence. But after re-reading all at once became clear.
November 23rd, 2009 at 11:46 pm
Run the specified script at the beginning of each volume. restore will pass the current device and volume number to the script. The script should return 0 to continue, 1 to prompt for a new tape, or any other exit value to abort the restore.
December 2nd, 2009 at 2:05 pm
What commands are to be used to delete all the files in a directory in linux system?
December 2nd, 2009 at 7:18 pm
ls -lr gives the long listing which is piped to the wc command ,wc -l counts the number of lines ..hwoever to count the files in the parent directory you have to navigate the parent directory or do something like this
January 29th, 2010 at 11:57 am
You probably need superuser (administrator) privideges to remove it. Type su, and your root password to get a root prompt.
February 1st, 2010 at 4:05 pm
It will not show you a file whose name begins with a period without the -a switch. That is non-negotiable. If you are not seeing any other files someone may have planted a rootkit on your machine. Rkhunter and chkrootkit are good programs to have and to run.
March 3rd, 2010 at 10:34 am
For copying and moving directories you can use the cp and mv commands just like you use them with files. Yeah, I know. If you’ve already tried to copy a directory with cp, you’ve probably noticed that cp just complains at you. Probably it says something like cp: omitting directory yadda yadda. You see, the cp command wants you to use the -r option if you want to copy a directory with its contents. The -r means “copy recursively”:
April 1st, 2010 at 11:11 am
Remove file from Clearcase view. First perform a checkout (“ct co”) of the file and directory. Past versions will be available from the archive although not visible in current view. Safer than “ct rmelem” which removes all knowledge of the file old and new.
May 4th, 2010 at 8:18 am
How to remove all the files inside a directory but not remove directory using rm command?
June 2nd, 2010 at 8:06 am
By using the the “/*” at the end, this path expands to “everything in the aryan directory”. Notice that this does not include the aryan directory itself. Therefore, the contents are deleted, but the directory itself is left intact.
June 11th, 2010 at 9:03 pm
You probably need superuser (administrator) privideges to remove it. Type su, and your root password to get a root prompt.
June 22nd, 2010 at 6:20 pm
dial up modem not make connection and not dial the modem
December 2nd, 2010 at 3:03 pm
i read Linux in my collage but i don’t take it seriously. so i have a less knowledge about Linux.
December 20th, 2010 at 10:31 pm
Probably if you put the content of the file to the database, then you dont need the original name, and filesystem access.
December 26th, 2010 at 11:32 pm
hello, how can i remove all sub directories in a folder?
January 3rd, 2011 at 11:13 am
can i get backup of all delete files?
January 16th, 2011 at 9:36 pm
That is great to hear! Thanks for letting us know they were helpful. All the best to you…
January 18th, 2011 at 11:06 pm
I am really thankful to this topic because it really gives great information “”,
January 19th, 2011 at 9:54 pm
I am really thankful to this topic because it really gives great information *’;
February 1st, 2011 at 7:23 pm
Decorating your office space is all about personalization. Make sure not to overdo it, though. You will want to keep your space organized and un-cluttered.
February 10th, 2011 at 3:04 pm
before a name indicates items marked for extraction. In verbose mode, the listing will include each item’s inode.
April 2nd, 2011 at 4:36 pm
If you are at your computer now, you may want to follow along. Open a terminal and then type whoami. (Remember to run all of the words together with no spaces, and press enter.) Here’s what you get..
May 26th, 2011 at 1:04 am
Excellent post!! I really like your site!!
June 2nd, 2011 at 10:53 am
Resources like the one you spoken concerning proper here could almost certainly be quite helpful to me! I can submit a hyperlink to it web page on my blog. I am certain my visitors should find that very valuable. Vast many thanks for the useful data i found on Area Details In any case, in my vocabulary, there aren’t significantly excellent provide like this.
June 18th, 2011 at 5:58 am
Hello, i believe that i saw you visited my site so i came to “return the favorâ€. I am attempting to obtain things to enhance my web site!I suppose its ok to make use of a few of your ideas!!
July 13th, 2011 at 2:10 am
Thx man…
July 18th, 2011 at 6:01 pm
Youre so cool! I dont suppose Ive learn something like this before. So nice to seek out somebody with some unique thoughts on this subject. realy thanks for beginning this up. this website is something that’s wanted on the web, somebody with a little bit originality. useful job for bringing something new to the internet!
July 21st, 2011 at 3:08 pm
I am a relatively new linux user, so I am not familiar w/ the linux lingo, so please answer in detail. I want to change the read,write,execute permissions of all the files w/in a directory named “_spe” so I did chmod 777 _spe.
August 4th, 2011 at 1:26 pm
l counts the number of lines ..hwoever to count the files in the parent directory you have to navigate the parent directory or do something like this
August 18th, 2011 at 1:49 am
I really like it. Great post!
August 30th, 2011 at 4:29 pm
I like your post. Good job!
August 30th, 2011 at 10:27 pm
Hi there very nice website!! Guy .. Beautiful .. Wonderful .. I’ll bookmark your web site and take the feeds additionally…I’m glad to seek out numerous helpful info right here in the submit, we’d like develop more techniques in this regard, thanks for sharing. . . . . .
September 1st, 2011 at 2:31 am
Great write-up, I’m normal visitor of one’s site, maintain up the nice operate, and It’s going to be a regular visitor for a lengthy time.
September 3rd, 2011 at 12:26 pm
The script should return 0 to continue, 1 to prompt for a new tape, or any other exit value to abort the restore,I dont suppose Ive learn something like this before. So nice to seek out somebody with some unique thoughts on this subject. realy thanks for beginning this up.
September 22nd, 2011 at 2:22 pm
It is very difficult to understand the concept of the Linux and there are various commands on which we have to work.
September 28th, 2011 at 12:13 pm
One must take caution when deleting files and directories via the command line. This could be a real time-saver compared to doing it via the GUI. However, if you delete something accidentally, you will not going to be able to retrieve it. It’ll be deleted forever.
October 1st, 2011 at 10:52 am
what is command to restore my abuntu or command recovery
and is there is any book explanation all linux command ?? plus what is the name
October 3rd, 2011 at 2:23 pm
Create a file and insert text into it. Display the starting part of the file.Show the usage of finger command. Create a file “mno” and “def” and compare their contents.
November 2nd, 2011 at 11:15 am
In Linux you just type it directly into the shell, you can either open a terminal or you can just hit ctrl+alt+f1 to get a full screen shell.
November 17th, 2011 at 5:15 pm
Linux is an interesting Operating System for work..It is more secure and reliable than other operating systems.
December 12th, 2011 at 3:24 pm
i am having the knowledge of how to delete a directory but i want to know how to change the permissions for a file and what command is used?
January 16th, 2012 at 12:23 pm
The post is very informative and useful for me. Thanks for sharing this post.
January 18th, 2012 at 12:10 pm
Use rmdir command. This command remove the directory if they are empty. yhanks for the post…
January 25th, 2012 at 9:52 am
This is very important information regarding the removing directory with the help of Linux command.This must help to the many of the user and who make career in the field of the linux OS.
January 26th, 2012 at 12:14 am
I’m a Windows user for many years but trying to study Linux. This post comes handy. Thanks.
February 1st, 2012 at 10:01 am
The script should return 0 to continue, 1 to prompt for a new tape, or any other exit value to abort the restore.
February 1st, 2012 at 4:07 pm
I recommended this post to my cousin.He love to read about Linux.He praised the idea to describe command a lot.Great share here.