Home » Linux rmdir |Linux Remove Directory

Linux rmdir |Linux Remove Directory

by Online Tutorials Library

Linux rmdir Command

This command is used to delete a directory. But will not be able to delete a directory including a sub-directory. It means, a directory has to be empty to be deleted.

Syntax:

Example:

For example, in the image below we have deleted directory ‘file1’ from ‘envelope’ successfully. Now we want to delete ‘created’ directory. But it shows error as it contain ‘file2’. Hence, to delete ‘created’ directory, first we have to delete ‘file2’. Then, we will be able to delete ‘created’ directory.

Linux-directories-rmdir-command1


rmdir -p

This command will delete a directory including its sub-directories all at once. In below picture, all sub-directories have been deleted with ‘rmdir -p’ command.

Linux-directories-rmdir-p1


You may also like