rm Linux Commands
What is Linux rm Command?
Explanation
rm COMMAND:rm linux command is used to remove/delete the file from the directory.
SYNTAX :
rm [options..] [file|directory]
OPTIONS:
-f |
Remove all files in a directory without prompting the user. |
-i |
Interactive. With this option, rm prompts for confirmation before removing any files. |
-r (or) -R |
Recursively remove directories and subdirectories in the argument list. The directory will be emptied of files and removed. The user is normally prompted for removal of any write-protected files which the directory contains. |
EXAMPLE:
- To Remove / Delete a file:
rmfile1.txt
Here rm command will remove/delete the file file1.txt.
- To delete a directory tree:
rm-irtmp
This rm command recursively removes the contents of all subdirectories of the tmp directory, prompting you regarding the removal of each file, and then removes the tmp directory itself.
- To remove more files at once
rmfile1.txtfile2.txt
rm command removes file1.txt and file2.txt files at the same time.