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/
12 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.