Ubuntu Linux: Delete directory command in Terminal
Q. Can you tell me command to delete a directory in terminal?
A. You need to use the rmdir utility / command. The rmdir utility removes the directory entry specified by each directory argument, provided it is empty. Arguments are processed in the order given. In order to remove both a parent directory and a subdirectory of that parent, the subdirectory must be specified first so the parent directory is empty when rmdir tries to remove it.
Remove / Delete directory called /tmp/foo
Open the terminal. Type the following command:
$ rmdir /tmp/foo
Recursive removal
Remove all files and directories (recursive removal):
$ rm -rf /path/to/directory
$ rm -rf /tmp/foo
Please note that you can also pass -p option to rmdir command. Each directory argument is treated as a pathname of which all components will be removed, if they are empty, starting with the last most component:
$ rmdir -p /tmp/x/y/z
E-mail
Print
Can't find an answer to your question? Contact us
Related Other Helpful FAQs:
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: recursive directory removal, rm command, rmdir command



Recent Comments
Today ~ 17 Comments
Today ~ 5 Comments
Today ~ 11 Comments
Yesterday ~ 24 Comments
Yesterday ~ 6 Comments