rm <file>Deletes a file. There is no undo.
Example
rm old.logRemoves files and directories. There is no recycle bin — deletion is immediate.
sudo apt install coreutilsrm <file>Deletes a file. There is no undo.
Example
rm old.logrm -i <file>Asks for confirmation for each file.
rm -I <files>Asks once before deleting more than three files.
Example
rm -I *.tmprm -f <file>Forces deletion without prompts and ignores missing files.
rm -- <file>Use -- to delete a file whose name starts with a dash.
Example
rm -- -weird-namerm -v <files>Prints each file as it is removed.
rmdir <dir>Removes an empty directory only — a safe choice.
Example
rmdir empty-folderrm -r <dir>Removes a directory and everything inside it.
Example
rm -r build/rm -rf <dir>Recursive and forced. Double-check the path; never run it with an unquoted variable that might be empty.
Example
rm -rf node_modulesfind <dir> -name "<pattern>" -deleteDeletes matching files anywhere in a tree.
Example
find . -name ".DS_Store" -deleteshred -u -n <passes> <file>Overwrites a file before deleting it. Not reliable on SSDs, copy-on-write or journaled file systems.
Example
shred -u -n 3 secrets.txt