rmdir Linux command
rmdir Linux Command
In this tutorial, we will learn about rmdir Linux Command with examples. rmdir is the short form for ‘remove directory’. The rmdir command deletes the specified directory from the Linux file system. The specified directory should be empty for the command to work.
Command Format
The command format is as follows:
$ rmdir <flags> directory_list
To know more about the command, type the man command
$ man rmdir
The directory_list is one or more directory paths of empty directories that rmdir deletes from the system.
Examples
Launch the Terminal and type the following commands.
Remove empty directory
For example, to remove directory automation:
$ rmdir automation
The command fails to remove a non-empty directory.
Create a directory and create a file in the directory.
Try to remove the non-empty directory with the rmdir command.
testingdocs@ubuntu:~$ mkdir automation
testingdocs@ubuntu:~$ cd automation/
testingdocs@ubuntu:~/automation$ touch sample.txt
testingdocs@ubuntu:~/automation$ cd ..
testingdocs@ubuntu:~$ rmdir automation/
rmdir: failed to remove ‘automation/’: Directory not empty
We will learn how to overcome this issue with the rm command.
rm command
https://www.testingdocs.com/rm-linux-command-with-examples/
We can remove multiple empty directories with the rmdir command. For example, to remove two empty directories:
$ rmdir emptydir1 emptydir2
–
Linux Commands Tutorial page:
https://www.testingdocs.com/linux-basic-commands-tutorial/
More Information on Ubuntu Linux:
https://ubuntu.com/