English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux rm Command

Linux Command大全

The Linux rm (full English name: remove) command is used to delete a file or directory.

Syntax

rm [options] name...

Parameters:

  • -i Ask for confirmation one by one before deletion.
  • -f Even if the original file attributes are set to read-only, they will be deleted directly without confirmation.
  • -r will also delete the directory and all files below it one by one.

Online Examples

Files can be deleted directly using the rm command, but if a directory is deleted, it must be accompanied by the option"-r", for example:

# rm test.txt 
rm: Do you want to delete the general file "test.txt"? y  
# rm homework  
rm: Cannot delete directory "homework": It is a directory  
# rm  -r homework  
rm: Do you want to delete the directory "homework"? y 

Delete all files and directories in the current directory, command line:

rm  -r  * 

Once a file is deleted using the rm command, it cannot be restored, so extra care must be taken when using this command.

Linux Command大全