Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux rm command

Linux rm command

Linux Command Reference Linux Command Reference

The Linux rm (short for "remove") command is used to delete a file or directory.

Syntax

rm [options] name...

Parameters:

Example

To delete a file, you can use the rm command directly; to delete a directory, you must use it with the "-r" option, for example:



# rm  test.txt 

rm:是否删除 一般文件 "test.txt"? y  

# rm  homework  

rm: 无法删除目录"homework": 是一个目录  

# rm  -r  homework  

rm:是否删除 目录 "homework"? y 

To delete all files and directories in the current directory, the command line is:



rm  -r  * 

Once a file is deleted with the rm command, it cannot be recovered, so this command must be used with extreme care.

Linux Command Reference Linux Command Reference