rm

rm (GNU) Cheatsheet #

The rm command is used to remove files or directories in Unix-like operating systems.

Basic Commands #

Command/OptionExampleDescription
rm filerm example.txtRemove a file
rm -r dirrm -r mydirRemove a directory and its contents
rm -f filerm -f example.txtForce remove a file, ignore nonexistent files
rm -i filerm -i example.txtPrompt before every removal
rm -r -i dirrm -r -i mydirPrompt before removing each file in a directory

Advanced Options #

Command/OptionExampleDescription
rm -d dirrm -d emptydirRemove an empty directory
rm -v filerm -v example.txtVerbose mode, show files as they are removed
rm --one-file-systemrm --one-file-system -r mydirRemove directory and its contents, only within the same file system
rm --no-preserve-rootrm --no-preserve-root -r /Ignore the safety check for removing /

This cheatsheet covers essential GNU rm options for file and directory removal.

rm

Explore our comprehensive cheatsheets to enhance your knowledge and efficiency. Each cheatsheet provides detailed command options, examples, and descriptions to help you master various tools and technologies.