trash-cli: Trash from the cmdline

trash_compDid you ever want to access your trash from the cmdline? There are instances where I needed it. trash-cli makes the process easier by providing a simple cmdline interface to the trash. This also means that it is supported by all desktop environments building on e.g. KDE, Gnome, LXDE, XFCE etc.

trash-cli records the original path, deletion date and permissions.


Run the following commands to install trash-cli:

$ git clone
$ sudo python install

In case you want to install it for the current user only:

$ git clone
$ python install --user


trash-cli supports the following commands:

trash-put  : trashes files and directories
trash-empty          : empty the trashcan(s)
trash-empty    : remove the files deleted before 
trash-list           : list trashed file
trash-restore        : restore a trashed file
trash-rm   : remove individual files from trash

While most commands are self-explanatory, here’s an example of trash-rm which also accepts a pattern:

$ trash-rm \*.o

You need to use quotes in order to protect pattern from shell expansion.

If you want to create a top-level Trash-can from the cmdline, here are the steps:

$ sudo mkdir --parent /.Trash
$ sudo chmod a+rw /.Trash
$ sudo chmod +t /.Trash

On GitHub: trash-cli


Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s