rm is a utility used for deleting files and directories from a file system. It is a simple, yet powerful command that is that is often aliased to prompt for confirmation.
Basic Syntax
rm [options] [target]
Here, options are the various flags that can be used to modify the behavior of the command. target consists of the file(s) / directories to be deleted.
Commonly Used Options
-
-f: This option is used to force the removal of files and directories, and suppresses any warnings or prompts. -
-r: This option is used to recursively delete directories and their contents. -
-i: This option prompts the user for confirmation before deleting each file. -
-v: This option displays verbose output, indicating which files are being deleted.
Useful Examples
-
rm file.txt: This deletes the file namedfile.txt. -
rm -rf /mnt/dir: This deletes the directory named/mnt/dirand all its contents without prompting or displaying any warnings. -
rm -i file.txt: This prompts the user for confirmation before deleting the file namedfile.txt. -
rm -f file.txt: This deletes the file namedfile.txtwithout prompting or displaying any warnings. -
rm -v file.txt: This displays verbose output, indicating that the file namedfile.txtis being deleted.
Leave a Reply