Linux rm command
The Linux rm (short for "remove") command is used to delete a file or directory.
Syntax
rm [options] name...
Parameters:
- -i Ask for confirmation before each deletion.
- -f Delete files directly even if they are read-only, without asking for confirmation.
- -r Delete the directory and the files under it recursively.
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