Cheatsheets
HomeWriteupsResourcesCheatsheets
Linux
Linux
  • Know Yourself and Your System
    • id
    • logname
    • uname
    • w
    • who
    • whoami
  • Surfing / Knowing Your File System
    • cd
    • df
    • du
    • ls
    • pwd
    • stat
    • tree
  • Knowing About Files / Commands
    • alias
    • file
    • info
    • whatis
    • apropos
    • man
    • help
    • history
    • script
  • Manipulating Files / Directories
    • touch
    • mkdir
    • rm
    • rmdir
    • cp
    • mv
    • ln
  • Interacting with Files
    • cat
    • head
    • less
    • middle
    • more
    • tail
  • STROPS / Text Manipulation
    • awk
    • cut
    • grep
    • jq
    • join
    • paste
    • sed
    • sort
    • tr
    • uniq
    • xargs
    • xclip
    • wc
    • tee
    • echo
    • comm
    • diff
    • patch
    • aspell
    • Combos
  • Formatting the Output
    • nl
    • fold
    • fmt
    • pr
    • printf
  • Searching / Finding
    • find
    • locate
    • which
    • whereis
    • type
  • Web Interaction
    • curl
    • wget
  • xxd
  • References
Powered by GitBook
On this page
  • Introduction
  • Syntax
  • Important Flags
  • Examples

Was this helpful?

  1. Manipulating Files / Directories

rm

rm linux command cheatsheet by Thamizhiniyan C S

Introduction

The rm command is used to remove files or directories.


Syntax

rm [OPTION]... [FILE]...


Important Flags

Flag
Description

-f

Forces the removal of all files or directories.

-i

Prompts for confirmation before removing.

-I

Prompts once before removing more than three files or when removing recursively.

-r

Removes directories and their content recursively.

-d

Removes empty directories.

-v

Provides a verbose output.

--help

Displays the help text.

--version

Displays the command version.


Examples

Command
Description

Removing one file at a time.

Removing more than one file at a time.

To remove an empty directory.

To remove a directory whose name starts with a hyphen (-).

Removes a file whose name starts with a hyphen (-).

To delete a directory that contains subdirectories and files (Recursive Deletion)

To delete a directory that contains subdirectories and files (Recursive Deletion), and the -v flag to list each step of the process.

-r : Deletes all files and sub-directories recursively in the parent directory.

Asks for confirmation before removing each file (Interactive Deletion).

Use the -i option to display a prompt asking for confirmation before removing a directory.

Overrides write protection and removes the file forcefully (Force Deletion).

Remove a write-protected directory.

To avoid confirmation when deleting a directory.

Elevate command privileges to remove a write-protected directory.

Use this command to remove a write-protected directory that contains other files and directories.

Displays the version of rm currently running on the system.

PreviousmkdirNextrmdir

Last updated 11 months ago

Was this helpful?

rm a.txt
rm b.txt c.txt
rm -d Example
rm -- [directory name]
rm -- -file.txt
rm -r Example
rm -r -v Example
rm -r *
rm -i d.txt
rm -d -i Example
rm -f e.txt
rm -d Example
rm -d -f Example
sudo rm -d Example
rm -rf 
rm --version