Normal usage is straightforward:
where name_of_directory corresponds with the name of the directory one wishes to delete. There are options to this command such as -p in Unix which removes parent directories if they are also empty.
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.
rm -r foo/bar/baz rm -rf foo/bar/baz
The DOS equivalent of this command is deltree, or in Microsoft Windows.
rd /s directory_name
Windows based on the NT kernel (XP, Vista, 7, 8, Server 2003/2008) are case insensitive, just like their earlier predecessors, unless two files of the same name and different case exist. Then case sensitivity applies when selecting which file to use, or if the case does not match either file, one may be chosen by Windows.
Having two files named the same with different case sensitivity is allowed either when Windows Services for Unix is installed or when the registry settings are set to allow it.
An example of the security risk is:
Using rd/rmdir and two directories with the same name and different case sensitivities exist, one of which contains valid data and/or programs, and the other contains incriminating materials and/or malware. If rd/rmdir gets executed without regard to case sensitivity and Windows chooses the legitimate folder to delete, the only folder left is the undesired one. Windows then uses this folder instead of the previously legitimate one to execute programs, and one may be led to believe it contains legitimate data.
- The Single UNIX® Specification, Issue 7 from The Open Group – Commands & Utilities Reference,
- Microsoft TechNet Rmdir article