The rmdir command in Linux is used to remove (delete) empty directories. Unlike the rm command, which can delete files and directories, rmdir is specifically designed to remove only empty directories. It’s a straightforward and safe tool for cleaning up unused directories in your filesystem.

In the above, ls command given the current list of directories and files. Once we executed rmdir dir01, this has deleted the empty folder and in the next ls command dir01 directory is not showing becasue this has already deleted.
If the directory is not empty, rmdir will not delete it and will return an error.

rmdir Command Options (Switches)
Although rmdir is a simple command, it does have a few options that can make it more versatile.
Description: The -p option allows you to remove a directory and its parent directories if they become empty after the removal. This is particularly useful when you want to clean up a nested directory structure.
-p (Remove Parent Directories)

--verbose (Verbose Output)
- Description: The
--verboseoption provides detailed output of whatrmdiris doing, which is helpful for tracking the deletion process, especially when working with multiple directories.

Limitations of rmdir
While rmdir is useful for removing empty directories, it’s important to note that it cannot remove directories that contain files or other directories. If you need to remove non-empty directories, you’ll need to use the rm command with the -r (recursive) option:
