Files
rm
Remove files and directories.
filesdeleteremovedirectoriesdangerous
Additional Notes
rm removes files. With recursive options, it can remove directories and everything inside them.
This command is powerful and dangerous because normal rm deletion does not move files to a desktop trash folder. In many cases, removed files are difficult or impossible to recover.
Syntax
rm [options] file...
Parameters
file: File, link, or directory path to remove.
Common Options
-i,--interactive: Ask before every removal.-I: Ask once before removing many files or recursive targets.-f,--force: Ignore missing files and never prompt.-r,-R,--recursive: Remove directories and their contents.-d,--dir: Remove empty directories.-v,--verbose: Show what is removed.
Examples
rm old.txt
Remove one file.
rm -i important.txt
Ask before removing.
rm -v *.tmp
Remove temporary files and show each deletion.
rm -r old-project
Remove a directory and everything inside it.
rm -I *.log
Ask once before removing many matching files.
find . -name "*.tmp" -print
find . -name "*.tmp" -delete
Safer workflow: preview with find, then delete.
Practical Notes
- Always check your current directory with
pwdbefore broad deletion. - Use
lsorfind ... -printbefore deleting wildcard matches. - Be very careful with
rm -rf; it removes recursively and ignores prompts. - Quote paths that contain spaces.
- To remove empty directories only, use
rmdirorrm -d. - For safer desktop-style deletion, use a trash tool if installed.