How to Manage Trash from Command Line using Trash-cli

Trash-cli is a free and open source commad line trash tool for Linux. Using Trash-cli, you can trash, restore trash file, remove file from trash, list trash files and more. It uses the same GNOME, XFCE and KDE trashcan but from the command line. It is written in Python and released under GNU General Public License v2.0.

How to Install Trash-cli on Ubuntu

To install the Trash-cli command line app, run below Trash-cli apt install command.

sudo apt install trash-cli

Install Trash-cli via PIPX:

You can also install it via pipx. In the terminal app, run below commands one by one.

sudo apt install pipx
pipx ensurepath
pipx install trash-cli

How to Use Trash-cli in Ubuntu

To trash a file in Ubuntu, use the below command.

trash-put file.txt

The above command will delete “file.txt” file from the “Home” directory. You can replace it with your file.

Also Read:  Librerama Arcade Mini Games Collection

List all trashed files from Trashcan

trash-list

How to Restore a trashed file

To restore the trash run below command. It will list all trash files with number.

trash-restore

trash restore

After that type the file number and and press the enter.

You can empty the trash can using below command.

trash-empty

It will completely delete all files from the trash.

If you liked this article, please subscribe to our YouTube Channel. You can also stay connected with us on X (Twitter) and Facebook.



Leave a Reply