rm

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 named file.txt.
  • rm -rf /mnt/dir: This deletes the directory named /mnt/dir and all its contents without prompting or displaying any warnings.
  • rm -i file.txt: This prompts the user for confirmation before deleting the file named file.txt.
  • rm -f file.txt: This deletes the file named file.txt without prompting or displaying any warnings.
  • rm -v file.txt: This displays verbose output, indicating that the file named file.txt is being deleted.

Leave a Reply

Your email address will not be published. Required fields are marked *

Comments

  1. […] Once installed, let’s first allow TCP traffic over your SSH port so that you don’t get locked out of…

  2. […] have the option to choose between Password and SSH key selection. Learn more about SSH keys here. It’s recommended…