Trash-cli : A Command Line Trashcan For Unix-like Systems

trash-cli - command line trashcan

We all know that when we delete a file/folder, they will be moved to a temporary location called ‘Trash’ or ‘Recycle bin’. We can then either delete the contents of Trash permanently or restore them if we need them again. However, if you’re a heavy command-line user and looking for a command-line alternative way to use Trashcan from commandline , you need to check ‘Trash-cli’ utility.  Trash-cli is a command-line trashcan for Unix-like systems. It uses the same trashcan used by GNOME, KDE, and XFCE, but you can use it from the Terminal. Using trash-cli, we can delete, restore items as the way we do in the graphical Trashcan.

In this brief tutorial, we will be discussing how to install and use ‘Trash-cli’ utility in Linux.

Trash-cli : A Command Line Recycle Bin For Unix-like Systems


Trash-cli is available on the default repositories of most Linux distributions.

To install it on Arch Linux and its derivatives:

sudo pacman -S trash-cli

On Debian, Ubuntu, Linux Mint:

sudo apt-get install trash-cli

On Fedora and other RPM based systems:

sudo dnf install trash-cli


sudo yum install trash-cli

If Trash-cli is not available on the repositories, you can compile and install it from sources.

To install it on system-wide, run the following commands one by one.

git clone
cd trash-cli
sudo python install

For user-level installation, run.

python install --user


Trash-cli supports the following functions:

  • trash-put – Delete files and folders
  • trash-empty – Empty the trashcan.
  • trash-list – List deleted files and folders.
  • trash-restore – Restore a trashed file or folder.
  • trash-rm – Remove individual files from the trashcan.

Let us see some practical examples.

To send a file named ‘file.txt’ to trashcan, run:

trash-put file1

Similarly, we can trash a directory using command:

trash-put dir1

You can verify it whether the files or folders have been sent to the trashcan in your file manager.

As you see in the above output, file1 and dir1 have been sent to Trash folder.

To view the contents of your Trashcan from Terminal, run:


Sample output would be:

2017-02-16 15:42:50 /home/sk/dir1
2017-02-16 15:41:47 /home/sk/file1

You can restore deleted items at any time using command:


It will ask you which file you’d like to restore. Just enter the number (0 or 1 in our case). The respective file will be restored. I wanted to restore dir1, so I entered 0(zero).

Sample output:

0 2017-02-16 15:42:50 /home/sk/dir1
1 2017-02-16 15:41:47 /home/sk/file1
What file to restore [0..1]: 0

now, the selected item will be restored.

To empty all items in the trashcan, you can use:


Also, you can remove a single folder/file from the Trashcan as shown below.

trash-rm file1

The above command will permanently delete the specified item i.e. file1.

Trash-cli also allows to remove contents older than x days. Say for example, to remove contents older than 7 days, run the following command:

trash-empty 7

You know now how to use trashcan from the commandline using trash-cli utility. I will be soon here with another interesting guide. Until then, stay tuned with OSTechNix.



Thanks for stopping by!

How can I benefit from this blog:

Have a Good day!!

You may also like...

  • neat, kind of want them to make it… rm (as alias or symlink) compatible, no more accidents, lol

  • “you can permanently _restore_ individual item as shown below.

    trash-rm file1”

    oops, this is gonna be a painful experience lol. please fix the text =)

    • SK

      Fixed it. Thank you.

  • This is so incredibly useful. I can’t believe I’m a Linux veteran and I had no idea this package even existed, until now. Thank you so much.