trash-cli: a command-line trashcan
Do you want an easy way to move undesired files to a trashcan using a Terminal, so you can restore them later if you want? trash-cli is your choice.
Table of Contents
Installation
Just install trash-cli
package with a package manager such as apt
or pacman
. Trashed files are located in ~/.local/share/Trash
by default, but you can change it with the --trash-dir=<TRASHDIR>
parameter.
Utilities
trash, trash-put
Use trash <file>
or trash-put file
to move a file to the trashcan.
trash-list
List all the contents of the trashcan. It displays the original file location. You can filter the output with grep
.
$ trash-list
2022-08-06 12:47:10 /home/ricardo/Downloads/sistemasOperativos/Metasploitable.vmx
2022-08-15 17:11:06 /home/ricardo/Documents/linux-guides/networking/red_hat_enterprise_linux-7-networking_guide-en-us.pdf
2022-08-11 17:01:54 /home/ricardo/Pictures/Webcam/2022-08-11-170019.jpg
trash-restore
Run trash-restore
to restore a file from the trashcan. It will display all trashcan files and you can select which one you want to restore (typing the corresponding number). You can also optionally include a relative or full path of the original location of the file.
$ trash-restore
0 2022-08-06 12:47:08 /home/ricardo/Downloads/sistemasOperativos/Metasploitable.nvram
1 2022-08-06 12:47:09 /home/ricardo/Downloads/sistemasOperativos/Metasploitable.vmsd
[trimmed output]
18 2022-08-21 13:07:28 /home/ricardo/Downloads/sistemasOperativos/slax-64bit-15.0.0.iso
19 2022-08-21 17:21:06 /home/ricardo/Documents/tests/d3.html
What file to restore [0..19]: 18
$ trash-restore tests/scan4all.csv
0 2022-08-06 16:28:47 /home/ricardo/Documents/tests/scan4all.csv
What file to restore [0..0]: 0
trash-rm
Remove files from the trashcan (it’s like running rm
, so be careful). Include the file name, a pattern or a full path.
$ trash-rm d3.html
If you have any suggestion, feel free to contact me via social media or email.
Latest tutorials and articles:
Featured content: