rm
rm linux command cheatsheet by Thamizhiniyan C S
Introduction
The rm
command is used to remove files or directories.
Syntax
rm [OPTION]... [FILE]...
Important Flags
Flag | Description |
---|---|
| Forces the removal of all files or directories. |
| Prompts for confirmation before removing. |
| Prompts once before removing more than three files or when removing recursively. |
| Removes directories and their content recursively. |
| Removes empty directories. |
| Provides a verbose output. |
| Displays the help text. |
| Displays the command version. |
Examples
Command | Description |
---|---|
Removing one file at a time. | |
Removing more than one file at a time. | |
To remove an empty directory. | |
To remove a directory whose name starts with a hyphen (-). | |
Removes a file whose name starts with a hyphen (-). | |
To delete a directory that contains subdirectories and files (Recursive Deletion) | |
To delete a directory that contains subdirectories and files (Recursive Deletion), and the -v flag to list each step of the process. | |
-r : Deletes all files and sub-directories recursively in the parent directory. | |
Asks for confirmation before removing each file (Interactive Deletion). | |
Use the -i option to display a prompt asking for confirmation before removing a directory. | |
Overrides write protection and removes the file forcefully (Force Deletion). | |
Remove a write-protected directory. | |
To avoid confirmation when deleting a directory. | |
Elevate command privileges to remove a write-protected directory. | |
Use this command to remove a write-protected directory that contains other files and directories. | |
Displays the version of rm currently running on the system. |
Last updated