Linux and Unix rm command
rm [OPTION]... FILE...
rm removes each specified FILE. By default, it does not remove directories; see Removing Directories below for details.
The removal process unlinks a filename in a filesystem from data on the storage device, and marks that space as usable by future writes. In other words, removing files increases the amount of available space on your disk.
The data itself is not destroyed, but after being unlinked, it becomes inaccessible. Remove your files wisely! The effects of an rm cannot be undone. (If what you want is to completely, irrevocably erase the data on the disk, use the shred command.)
If the -I or --interactive=once option is given, and there are more than three files or the -r, -R, or --recursive are given, then rm prompts the user for whether to proceed with the entire operation. If the response is not affirmative, the entire command is aborted.
Otherwise, if a file is unwritable, standard input is a terminal, and the -f or --force option is not given, or the -i or --interactive=always option is given, rm prompts the user for whether to remove the file. If the response is not affirmative, the file is skipped.
|-f, --force||Ignore nonexistant files, and never prompt before removing.|
|-i||Prompt before every removal.|
|-I||Prompt once before removing more than three files, or when removing recursively. Less intrusive than -i, while still giving protection against most mistakes.|
|--interactive[=WHEN]||Prompt according to WHEN: never, once (-I), or always (-i). If WHEN is not specified, then prompt always.|
|--one-file-system||When removing a hierarchy recursively, skip any directory that is on a file system different from that of the corresponding command line argument|
|--no-preserve-root||Do not treat "/" (the root directory) in any special way.|
|--preserve-root||Do not remove "/" (the root directory). This is the default behavior.|
|-r, -R, --recursive||Remove directories and their contents recursively.|
|-v, --verbose||Verbose mode; explain at all times what is being done.|
|--help||Display a help message, and exit.|
|--version||Display version information, and exit.|
By default, rm does not remove directories. If the -r (--recursive) option is specified, however, rm will remove any matching directories and their contents.
Filenames Starting With A Dash
To remove a file whose name begins with a dash ("-"), you can specify a double dash ("--") separately before the filename. This is necessary so that rm does not misinterpret the filename as an option.
For instance, if there is a file in your current directory named "-file.txt", you can delete it with the command
rm -- -file.txt
Or, you can delete it by referring to it with a pathname. For instance, if the file "-file.txt" was located in the directory "/home/chope", you could delete it using:
...or, if /home/chope is your current directory,
...will work as well.
Remove the file myfile.txt.
rm -rf mydirectory
Remove the directory mydirectory, and any files and directories it contains, without prompting for confirmation.