Install and Use Trash CLI on Linux Mint 20 - A step by step guide ?

Trash CLI is a very handy tool for deleting or restoring files from a Linux system's trash. You can also delete files from your system's trash manually, however, if you have such a utility available, it gets very convenient for you to perform this task via the terminal instead of going all the way to your system’s trash.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Linux system tools queries.

In this context, we shall look into how you can install and use the Trash CLI utility on a Linux Mint 20 system.


How to Install Trash CLI on Linux Mint system ?

To install the Trash CLI on your Linux Mint 20 system, you just need to execute the following command:

$ sudo apt update && sudo apt install trash-cli

You will have to hit the "Y" character to confirm your installation once you will be asked for it.


How to use Trash CLI on Linux Mint 20 ?

Now, to use the Trash CLI on your system after installing it, you need to perform the following outlined steps.


1. View the Contents of your System's Trash

To begin, you need to view the contents of your system's trash because after all, we will attempt to empty it. Therefore, the trash must hold something in it. You can click on the file manager icon and go to the Trash tab to view its contents.

Alternatively, you can launch the terminal and run the below command:

$ trash-list


2. Remove all the Contents of your System's Trash 

Here, we will try to remove all of these files by running the below command:

$ trash-empty

Note that the above command will not generate any output. Therefore, to verify if the contents of the Trash have actually been deleted or not, you will have to perform the following step.


3. Verify if all the Contents of your System's Trash have been removed or not

You will need to run the "$ trash-list" command once again but this time it will not produce any output because your Trash has been cleaned up successfully:

$ trash-list


How to Uninstall Trash CLI from your Linux Mint 20 system ?

To uninstall the Trash CLI from your system, you will need to execute the following command:

$ sudo apt-get purge --autoremove trash-cli


[Need to Install any Software on Linux Mint system ? We can help you. ]

This article covers how you can install and use the Trash CLI on a Linux Mint 20 machine. In fact, trash-cli is a command line interface that trashes files and records the original absolute path, deletion date, and associated permissions. It uses the same trashcan used by popular Linux desktop environments such as KDE, GNOME, and XFCE which can be invoked from the command line (and via scripts).


Trash-cli provides these commands:

$ trash-put           #trash files and directories.
$ trash-empty         #empty the trashcan(s).
$ trash-list          #list trashed files.
$ trash-restore       #restore a trashed file.
$ trash-rm            #remove individual files from the trashcan.


How to Install Trash-cli in Linux ?

The straightforward way of installing trash-cli is by using easy install tool as follows:

$ sudo apt-get install python-setuptools		#Debian/Ubuntu systems
$ sudo yum install python-setuptools #RHEL/CentOS systems
$ sudo easy_install trash-cli

Related Posts