How to remove directories or files in Linux
This tutorial explains how to remove directories or files in Linux.
You can use rm command to remove directories or files in Linux environment.
First we can check how to use rm in Linux command line.
- How to remove one single file in Linux
- rm space filename
- Remove file in the specific path
- rm directory path/filename
- How to remove multiple files
- rm file1 file2
#rm file1.txt file2.txt
There are a lot of options available in rm. Use man rm command and check all things. Now we are going to check what the options available in rm and how it uses for the command line.
rm [option] filename or directory
- -f, –force remove file or directory without asking confirmation message.
- -i asking user confirmation before delete file. This is one of the secure options to delete files in the Linux command line. The message will different empty files vs. other files.
- -I if you are going remove more than 3 files you can use this option.
- -r, -R, –recursive remove files or directory safely
- -d, –dir remove empty directory
- –help rm help page
- How to remove all files in directory and remove files Linux using specific extension.