How to remove the content of a directory: Linux

How to remove the content of a directory: Linux

In case you want to delete all the content of a Linux directory (including all the files and subdirectories), there are very simple and fast ways to achieve that. Here we explain to you everything you need to know.

To recursively erase the content of a directory:

  • Either go to the directory and type: rm -rf *
  • Or, type rm -rf path_of_your_directory/*

The r means recursively (to remove subdirectories), and f means force (does not ask for confirmation).

any more questions about linux? check out our forum!