rm (BSD) Cheatsheet #
The rm
command is used to remove files or directories in Unix-like operating systems.
Basic Commands #
Command/Option | Example | Description |
---|---|---|
rm file | rm example.txt | Remove a file |
rm -r dir | rm -r mydir | Remove a directory and its contents |
rm -f file | rm -f example.txt | Force remove a file, ignore nonexistent files |
rm -i file | rm -i example.txt | Prompt before every removal |
rm -r -i dir | rm -r -i mydir | Prompt before removing each file in a directory |
Advanced Options #
Command/Option | Example | Description |
---|---|---|
rm -d dir | rm -d emptydir | Remove an empty directory |
rm -v file | rm -v example.txt | Verbose mode, show files as they are removed |
rm -P file | rm -P example.txt | Overwrite the file before removing (secure deletion) |
This cheatsheet provides key BSD rm
options for file and directory removal.