Command line recycle bin for Linux
rm is a great tool that gives users enough power to inadvertently erase data. While the data may be recoverable, there is a tool that gives users recycle bin behavior.
What is trash-cli
trash-cli is a Python tool that implements the freedesktop.org trash specification. In contrast to rm, users can recover deleted files easily.
Installing trash-cli
The recommended way to install trash-cli is through pip (the Python package manager):
1pip3 install trash-cliAlternatively, trash-cli is available on some package managers:
Debian/Ubuntu:
1sudo apt install trash-cliArch:
1pacman -S trash-cliFedora:
1dnf install trash-clitrash-cli simple usage
Using trash-cli is straightforward.
Trash a file:
1trash path/to/fileTrash many files:
1trash path/to/file1 path/to/file2List trashed files:
1$ trash-list
22023-05-20 21:43:02 /Users/thomas/example2.txt
32023-05-20 21:43:02 /Users/thomas/example1.txtRemove specific trashed files:
1$ trash-rm example2.txt
2$ trash-list
32023-05-20 21:43:02 /Users/thomas/example1.txtRestore trash:
1$ trash-restore
2 0 2023-05-20 21:43:02 /Users/thomas/example1.txt
3What file to restore [0..0]: 0Lastly, emptying trash:
1$ trash-empty
2Would empty the following trash directories:
3 - /Users/thomas/.local/share/Trash
4Proceed? (y/n) y