Linux rm command
Linux rm (full English spelling: remove) command is used to delete a file or a directory.
Syntax
rm [options] name...
Parameters:
- -i Ask for confirmation one by one before deletion.
- -f Even if the original file attribute is set to read-only, delete it directly without confirmation.
- -r Delete the directory and all files under it recursively.
Examples
To delete a file, you can directly use the rm command; if you delete a directory, you must use 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 under the current directory, the command line is:
rm -r *
Once a file is deleted by the rm command, it cannot be recovered, so you must be especially careful when using this command.
Other Extensions
Linux Command Encyclopedia