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,
enter:
rmdir mydir
If 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 rm command
with the -r option for recursive deletion. Be
very careful with this command, because using the rm -r
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
Unix prompt:
rm -r mydir
For more information on the rmdir and the rm -r
commands, see their man pages. At the Unix prompt, enter:
man rmdir
Last modified on November 01, 2008.







