Remove directory or delete directory using rmdir command.
Remove directory or delete directory using rmdir command.
Using the rmdir command to delete empty directory or remove empty directory from the Linux system.
Remove directory.
The rmdir command usually use to delete or remove empty directory in the Linux system, there is several program or command that have the ability to remove or delete directory form Linux system. This article show the step by step using 'rmdir' command to remove or delete empty directory from the Linux Fedora Core system.
Remove or delete empty directory.
The rmdir without any options can be use to delete only a empty directory. Step shown below remove empty directory from the system
1. Before we can delete or remove a directory we need to create the directory first, or we can use the available directory in the system (not recommended). To be save, create empty directory name 'directory_example' directory with 'mkdir' command.
[melinda@fedora ~]$ mkdir directory_example
2. Verify directory creation using ls command.
[melinda@fedora ~]$ ls -l
total 4
drwxr-xr-x 2 melinda melinda 4096 Apr 7 05:15 directory_example
[melinda@fedora ~]$
3. Using the rmdir command to delete the empty directory.
[melinda@fedora ~]$ rmdir directory_example/
[melinda@fedora ~]$
or using the rmdir with option -v for verbose output.
[melinda@fedora ~]$ rmdir -v directory_example
rmdir: removing directory, directory_example
[melinda@fedora ~]$
Delete the empty directory tree.
You can use the rmdir command to delete list of empty directory include with their parents directory.
1. Create empty directory using mkdir command with option -p.
[melinda@fedora ~]$ mkdir -p list/of/empty/directory
2. Verify the empty directory list using 'tree' command.
[melinda@fedora ~]$ tree list
list
`-- of
`-- empty
`-- directory
3 directories, 0 files
[melinda@fedora ~]$
3. Test using the rmdir command to delete the 'list' directory.
[melinda@fedora ~]$ rmdir -p list
rmdir: list: Directory not empty
[melinda@fedora ~]$
Note: The execution of rmdir fail because the 'list' directory contain other directory ( directory 'of', 'empty' and 'directory').
4. Now using the same command above; but now try using the 'tab' key for command completion till you get the same command shown in the example below.
[melinda@fedora ~]$ rmdir -p list/of/empty/directory/
[melinda@fedora ~]$
or using the 'rmdir' with -pv option.
[melinda@fedora ~]$ rmdir -pv list/of/empty/directory/
rmdir: removing directory, list/of/empty/directory/
rmdir: removing directory, list/of/empty
rmdir: removing directory, list/of
rmdir: removing directory, list
[melinda@fedora ~]$
Getting help on 'rmdir' command:
[melinda@fedora ~]$ info rmdir
[melinda@fedora ~]$ rmdir --help
[melinda@fedora ~]$ man rmdir
Related:
Using rm command to remove file and directory.
Make new directory with mkdir command.
Keywords: remove directory, delete directory, rmdir, rmdir command, delete empty directory, remove empty directory, linux rmdir command.
- Add new comment
- 10468 reads
- Email this page
Thanks for Reading and Check Other Popular Linux Topics
All time:
- Configure and Setup Squid Cache Proxy Server on Fedora Core.
- Using Linux rm command to delete, remove hidden files and folder - Basic Linux Command.
- Copy Linux Files and Copy Directory Using cp Command - Linux Basic Command.
- Moving or rename files and directory using Linux mv command - Basic Linux Command.
- Add, view, edit and configure route and static route on Linux Fedora Core - Linux Server Configuration.
- Get and display the size of file and directory in Linux system using du command.
- Step by step Install Setup and Configure Linux Fedora Core Server and Network Management with Screen Shot and Example.
- Create file and display file contents in Linux using cat command.
- Configure Squid to block HTTP request to specific web sites.
- Example of samba smbpasswd file and samba smbusers configuration file.

Recent comments
10 hours 5 min ago
1 day 7 hours ago
1 day 12 hours ago
1 week 2 days ago
1 week 6 days ago
5 weeks 6 days ago
10 weeks 4 days ago
10 weeks 4 days ago
11 weeks 2 days ago
11 weeks 5 days ago