Table of Contents
Use rm to delete a file, rmdir for an empty directory, and rm -ri to review deletions inside a nonempty directory. These commands normally bypass the desktop Trash. Before pressing Enter, check the path and make sure you have a backup of anything you want to keep.
Delete one file or a short list of files
Use pwd to check your current folder and ls -l -- "file.txt" to check the target. Then use the interactive option:
rm -i -- "file.txt"
rm -i -- "file one.txt" "file two.txt"Quotes keep names with spaces together. The -- ends option parsing, so a file name beginning with a hyphen is handled as a name. Ordinary rm may remove a file without asking, while -i requests confirmation.


The older examples below illustrate single-file and multi-file removal. For a manual cleanup, use the interactive commands above so you can review each target.


Remove an empty or nonempty directory
rmdir -- "empty-folder"
rm -ri -- "old-test-folder"rmdir stops if the directory still contains files. For a nonempty directory, first inspect it with ls -la -- "old-test-folder" so you can see hidden files too. Use the recursive command only if you intend to remove the folder and its contents.
The older screenshot shows a force option. The example above deliberately asks for confirmation and uses a clearly named local folder.

If you expect to recover the item later, use your file manager’s Move to Trash command instead. Avoid adding administrator privileges or broad wildcards just to get past a permission error.
Reader Comments 0
Sign in with email or Google to join the discussion.