Unix Command - rmdir

rmdir is a command which will remove an empty directory on a Unix-system. It cannot be capitalized. Normal usage is straightforward where one types:

rmdir name_of_directory

Where name_of_directory corresponds with the name of the directory one wishes to delete. There are options to this command such as -p which removes parent directories if they are also empty.

For example:
rmdir –p foo/bar/baz

Will first remove baz/, then bar/ and finally foo/ thus removing the entire directory tree specified in the command argument.

Often rmdir will not remove a directory if there is still files present in the directory. To force the removal of the directory even if files are present usually the -rf flag can be used. For example:

rmdir -Rf for/bar/baz