How to Delete a Folder using Terminal

In this article, we are going to see how to delete a folder using terminal.

If you want to delete an empty folder, then you can use the following command :

$ rmdir emptyfoldertodelete

This will delete the folder if it is empty. But if the folder is not empty, then it will display one error message like this.

rmdir: emptyfoldertodelete: Directory not empty

If you want to delete the folder which is not empty, then you can use the following command :

$ rm -r foldertodelete

This will delete the folder even if the folder is not empty.