花美男为中国互联网事业而奋斗

How to delete a non-empty directory in Terminal?

来源:askUbuntu 阅读(0)次 评论(0)

How do I delete the following directory?

I typed:

rmdir demo

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 demo directory.


In case user doesn't have the permission to delete the folder:

Add sudo at the beginning of the command :

sudo rm -rf folderName

Otherwise, without 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

FYI: you can use letters -f-r-v:

  • -f = to ignore non-existent files, never prompt

  • -r = to remove directories and their contents recursively

  • -v = to explain what is being done




From: http://askubuntu.com/questions/217893/how-to-delete-a-non-empty-directory-in-terminal

标签:linuxterminal
上一篇:how to use sudo? 下一篇:How to Use WGET Command On Ubuntu

相关推荐