How to delete/remove all files from a directory in ubuntu (Linux) via Terminal?

 

Image Source:- http://spreadubuntu.org/files/ubuntu_p.png

 

To remove the folder with all its contents(including all sub folders):

rm -rf /path/to/directory

To remove all the contents of the folder(including all sub folders) but not the folder itself:

rm -rf /path/to/directory/*

To remove all the “files” from inside a folder(not removing sub folders):

rm -f /path/to/directory/*

 

Definitions

rm – stands for “remove”

-f – stands for “force” which is helpful when you don’t want to be asked/prompted if you want to remove an archive, for example.

-r – stands for “recursive” which means that you want to go recursively down every folder and remove everything
linux,ubuntu,terminal,delete,remove,folder,directory