Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Trash CLI Cheatsheet


On Ubuntu 22.04, it was as easy as running:

sudo apt update && sudo apt install trash-cli


List Trashed Files


Move Files To Trash

Move Specific File To Trash

trash-put file1

Use With Find To Trash Specific Files

You can combine the trash-put command with find to trash specific files that you find. For example, the command below will trash files from the current directory that are older then 30 days

find .  -maxdepth 1 -type f -mtime +30 | xargs --no-run-if-empty trash-put

Restore Trashed Files

If you want to restore a file from trash, run:


This will give you an indexed list of files. Press the number corresponding to the file you wish to restore and it will restore it to its original location.

Empty Trash

Remove Files Trashed More Than X Days

trash-empty $NUM_DAYS

Remove All Trashed Files



Last updated: 22nd March 2024
First published: 22nd October 2023