Using the rm command, you can delete a file or directory.

Rm is short for remove.

1 syntax

rm [options] name...
Copy the code
parameter instructions
-i Before deleting a vm, confirm whether to delete the vm one by one.
-f Even if the original file property is set to read-only, it is deleted directly without confirmation.
-r Delete files and directories under the specified directory.

Example 2

2.1 Deleting a File

To delete a file, run the rm command:

2.2 Deleting a Directory

To delete a directory, you must use the “-r” parameter:


Rm -rf command is used more, that is, delete a directory and the following files and descendants of the directory, even if it contains read-only files, also delete.

Note: Once a directory or file is deleted using the rm command, it cannot be restored, so use this command with caution.