Rm command
From NetworkStuff
A CLI command available on most Linux platforms; used to remove (delete) files and directories.
Contents |
Usage Syntax
rm [options] (file_name | directory_name | reg_exp)
Common options include;
- -f - force removal, ignore non-existent files, never prompt
- -i - interactive; prompt before every removal
- -I - prompt once before removing more than three files or directories, or when removing recursively
- -r or -R - remove directories and their contents recursively
- --one-file-system - when removing recursively, skip any directory that is on a file system different from that of the starting point initially specified
- -v - verbose; display detailed information on what is being done
Usage Examples
rm -rf * - remove all files and directories recursively, without prompting for confirmation, from the present working directory down. Very dangerous!
rm -rI * - remove all files and directories recursively, prompting for confirmation only once, from the present working directory down.
Usage Notes
This command supports most Shell Expansion Characters and Regular Expressions
Most Red Hat based Linux distributions (Fedora, Mandriva, CentOS) use an alias of rm of rm -i which results in a prompt for every file or directory removal even if the -f option is used. To prevent this behaviour, remove the alias using this command: unalias rm.
Command Combinations
See our Remove Files Found By Find article
Linux Usage Notes
With most Linux or Unix commands;
- Non root users may need to prefix commands with the sudo command, for example: sudo chmod 644 *
- Brief help can be displayed using the -h or --help parameter, for example: chmod --help
- A full command manual can be displayed using the man command followed by the command name, for example: man chmod
- Sometimes 'info' pages are used instead of or to provide more information than man pages; for example: info chmod
- Version information can normally be display using the -v, -V or --version parameter, for example: chmod --version. However, this paramater is also frequently used to display verbose output.
Related Files
The rm executable is normally found here: /bin/rm
Related Commands
Use the ls command to list directory contents
Use the cd command to change the current (working) directory
Use the ln command to link files
Use the cp command to copy files and directories
Use the mv command to move files and directories
Use the pwd command to display (or print) the current working directory
Use the mkdir command to create (or make) a new directory
Command Equivalents
The Cisco command equivalents are the delete command (for files) and the rmdir command for directories
The Windows Command Prompt equivalents are the delete command (for files) and the rmdir command for directories
Related Articles
Information on other Linux commands
Information on F5 BigIP commands
Information on Cisco commands
Information on Vyatta commands
Information on Extreme commands
Information on Nortel commands
Information on Zebra commands
Information on Windows commands
Information on Secure Platform commands
Information on Blue Coat SGOS commands
Information on Nokia IPSO commands





