Updated: 3 November 2026 · Applies to: trash-cli
trash-cli moves files to the same trash can used by desktop environments like GNOME, KDE and XFCE, recording each file's original path and deletion date, instead of deleting them outright the way rm does. It gives a command-line rm replacement you can actually recover from, which matters most in a script or a habit you have built around rm that one day targets the wrong path.
Install trash-cli
trash-cli is a Python package; install it with pip, not easy_install, which has been removed from current Python entirely:
apt install -y python3-pip pip3 install --break-system-packages trash-cli
On AlmaLinux, Rocky Linux or RHEL:
dnf install -y python3-pip pip3 install trash-cli
--break-system-packages is needed on current Debian and Ubuntu because the system Python is externally managed and pip refuses a global install without it by default; this is expected and safe for a small, well-known utility like this one. If you would rather avoid that entirely, install it in an isolated environment instead:
pip3 install --user pipx pipx install trash-cli
The commands trash-cli provides
trash-put: move files or directories to the trash.trash-list: list everything currently in the trash.trash-restore: restore a trashed file to its original location.trash-empty: empty the trash.trash-rm: remove specific files from the trash without restoring them.
Trash a file
trash-put notes.txt
List what is in the trash
trash-list
2026-11-01 10:30:48 /home/user/notes.txt 2026-11-02 13:40:41 /home/user/draft.txt
Search the trash for a specific file
trash-list | grep notes
Restore a trashed file
trash-restore
This lists every trashed file with a number next to it and prompts you to pick which one to put back in its original location.
Empty the whole trash
trash-empty
Empty only what is older than a given number of days
trash-empty 7
This removes only items trashed more than 7 days ago, leaving anything more recent still recoverable.
Remove files matching a pattern, without restoring them
Quote the pattern so your shell does not expand it before trash-rm sees it:
trash-rm '*.tmp'