To delete an empty directory named subdir2, use the following command:
I check first the directory, delete the directory when confirmed and verify the directory is deleted.
You can remove a directory in a different location by changing what is after rmdir. To remove a directory in /home/hadi/Music, if you already in your /home directory, you can use the following:
Or from anywhere using an absolute path, you can use this:
Or from anywhere using a path shortcut, you can use the following command:
The directory must be empty to be removed using rmdir. However, you can remove a directory with its contents by using rm.
Note: Anything that has been deleted using rmdir cannot easily recovery, so proceed carefully.