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-cli
Alternatively, trash-cli
is available on some package managers:
Debian/Ubuntu:
1sudo apt install trash-cli
Arch:
1pacman -S trash-cli
Fedora:
1dnf install trash-cli
trash-cli
simple usage
Using trash-cli
is straightforward.
Trash a file:
1trash path/to/file
Trash many files:
1trash path/to/file1 path/to/file2
List trashed files:
1$ trash-list
22023-05-20 21:43:02 /Users/thomas/example2.txt
32023-05-20 21:43:02 /Users/thomas/example1.txt
Remove specific trashed files:
1$ trash-rm example2.txt
2$ trash-list
32023-05-20 21:43:02 /Users/thomas/example1.txt
Restore trash:
1$ trash-restore
2 0 2023-05-20 21:43:02 /Users/thomas/example1.txt
3What file to restore [0..0]: 0
Lastly, emptying trash:
1$ trash-empty
2Would empty the following trash directories:
3 - /Users/thomas/.local/share/Trash
4Proceed? (y/n) y