ARCHIVED: In Unix, how do I remove a directory?
To remove a directory that you own, use the
rmdir command. For
example, to remove a subdirectory named
mydir that exists
in your current working directory, at the Unix prompt,
mydir exists, and is an empty directory, it will be
removed. If the directory is not empty or you do not have permission
to delete it, you will see an error message.
To remove a directory that is not empty, use the
-r option for recursive deletion. Be
very careful with this command, because using the
command will delete not only everything in the named directory, but also
everything in its subdirectories. If you don't use this command very
cautiously, you risk deleting all or most of your files.
If the subdirectory
mydir exists in your current
directory and it is not empty, you can delete it by entering at the
rm -r mydir
For more information on the
rmdir and the
commands, see their man pages. At the Unix prompt, enter:
Last modified on November 01, 2008.