How to delete a non-empty directory in Terminal?
How do I delete the following directory?
This error comes up:
rmdir: failed to remove `demo': Directory not empty
I'm unable to remove a directory like "New Folder" using all the above detailed commands. It's double worded. But I want to remove that directory.
Use the below command :
rm -rf demo
It deletes all files and folders contained in the
In case user doesn't have the permission to delete the folder:
sudo at the beginning of the command :
sudo rm -rf folderName
sudo you will be returned permission denied. And it's a good practice to try not to use
-f while deleting a directory:
sudo rm -r folderName
Note: this is assuming you are already on the same level of the folder you want to delete in terminal, if not:
sudo rm -r /path/to/folderName