Linux rm -rf command

This post will guide you how to delete all files in a given directory using rm command in Linux system. How to delete multiple sub-directories with one Linux command. How to use rm -rf command on a linux operating system.

In Linux, you can use the rm command to remove file or directory, and it can not be use to delete directories directory. so if you want to remove directories with rm command, you need to use an option -rf with rm command. on a Linux.

Linux rm -rf command


To remove or delete a file, you just need to use the rm command, type:

# rm fio.txt

To remove two or more files, you need to pass all file names to rm command, type:

# rm fio1 fio2 fio3

To remove all files and its sub-directories, and you need to use the -rf option for rm command, type:

# rm -rf mydir

Note: you do not remove / directory using rm command, and it will remove all files in your Linux system, as all files are located in / directory in Linux system.

To remove a blank directory, you can also use the rmdir command, type:

# rmdir mydir

To get more information about rm command, you can run the one of the below command:

# man rm

or

#rm --help

You might also like:

Sidebar



back to top