rm command is used to delete the files and directories in Linux. rm stands for remove. By default, rm command does not remove directories. If the –interactive=once or -I option or -R, -r, or –recursive is given for more than three files, then rm will prompt the user whether to proceed with the entire operations. If there is no affirmative response, then the entire command will be aborted.
If a file is in read-only format and if the input is given with -i or without -f, then rm prompts the user whether to remove the files. If the user response is not affirmative, then the file will not be removed.
Syntax
rm [options] [-r directories] filenames
Options:
– i : is used to prompting before every removal.
– d : is used to delete an empty directory.
-r, -R, — recursive: option deletes all the files and subdirectories in the parent directory recursively.
– v, -– verbose: option is used explain at all times what is being done.
— version: option is an output version of the information and exit.
-f, — force: option ignores nonexistent files and it will never prompt.
— no-preserve-root: option is used to do not treat ‘/’ in a special way.
— preserver-root: option is used to do not remove ‘/’ (default)