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/
18 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