Safe Delete
(Recycle Bin for the Terminal)
Last updated 2026-08-20 · 5 notes · 4 tags
Tags: trash safety linux wsl
Unlike Windows Explorer, Linux rm permanently deletes files. There is no built-in Recycle Bin for that command. This is the solution...
rm myfile.py
If the file was never committed to Git and not backed up, recovery is usually impossible.
Note: This guide works the same on WSL and native Linux.
Install trash-cli
sudo apt update
sudo apt install trash-cli
Basic usage
Instead of permanent delete:
trash-put path/to/file
List trash:
trash-list
Restore (interactive list):
trash-restore
Empty trash:
trash-empty
Only remove items older than 30 days:
trash-empty 30
Note:
trash-putmoves files to a Trash folder; it does not wipe the disk immediately.
Make rm safer with an alias
Edit your shell config:
nano ~/.bashrc
Add at the end:
alias rm='trash-put'
Save, exit, then reload:
source ~/.bashrc
Check:
alias rm
Expected: alias rm='trash-put'
Note: After this, typing
rm file.pysends the file to Trash instead of deleting it permanently.
Permanent delete when you really mean it
Bypass the alias:
\rm file.py
or:
command rm file.py
Note: Use permanent delete sparingly. Prefer Git history for important work you might need again.
Recommended workflow
- Day-to-day experiments: delete with
rm(aliased to trash) and restore if needed. - Anything that took real effort: commit to Git before you clean up. Trash protects accidents between commits; Git protects longer-term history.
Note: Trash is not a backup system. It lives on the same machine.
Summary
| Task | Command |
|---|---|
| Install | sudo apt install trash-cli |
| Delete to Trash | trash-put file.py or aliased rm file.py |
| List | trash-list |
| Restore | trash-restore |
| Empty | trash-empty |
| Permanent delete | \rm file.py |
| Check alias | alias rm |
This project chronicles ideas, decisions and lessons I have gleaned from building with AI. The goal is to help non-technical users get familiar with these tools and techniques, so that they may be able to use them effectively. At times, I have also made the use of AI tools to augment or refine the content.
Readers are responsible for using any commands or instructions published here with due caution. The creator of this site accepts no responsibility for any system damage, data loss or other consequences, resulting from the application of this content.