Is there a way to empty the trash/wastebasket from the command line?
Solution 1
At least in Debian and Ubuntu, you can install the trash-cli
package. This provides a number of commands for working with FreeDesktop.org Trash Specification compliant trash cans, like GNOME's.
/usr/bin/trash
/usr/bin/list-trash
/usr/bin/restore-trash
/usr/bin/empty-trash
To remove all trashed files, use emtpy-trash
. It can also just remove files that have been in the trash more than a certain number of days. Use empty-trash x
, where "x" represents the number of days.
I personally have set up a cron job that runs daily to get rid of trash over a week old.
Solution 2
There is no such thing like a system trash in Linux, but its common for many desktop environments to use ~/.Trash
as trash folder. This depends on the window manager you are using.
For Gnome you can empty this folder with:
rm -rf ~/.Trash/*
Related videos on Youtube
Matthew
Updated on September 17, 2022Comments
-
Matthew over 1 year
This would be great especially considering the latest version of Ubuntu is very slow when displaying directories on my PC...
-
Adam Monsen over 8 yearsTry
rm -rf ~/.local/share/Trash
. Found in askubuntu.com/a/468722/2273
-
-
Michael Mrozek over 13 yearsI suspect the window manager has little to do with what folder is used for trash storage, but I know what you meant :)
-
Steven D over 13 yearsOn my gnome system the trash is found in
~/.local/share/Trash
. -
amarillion over 13 yearsThat is only true if all your stuff is on one partition. Every drive/partition has its own trash (wouldn't make sense to move a multiple GB file over to a different drive to store it in the trash)
-
Cole over 13 yearsOh, I wasn't aware of multiple partitions :-) @Steven D: what gnome version are you using? maybe this has changed or is partly distribution specific...
-
livibetter over 13 yearsI wonder if this trash-spec would help creating a more generic solution?
-
Steven D over 13 years@echox I checked it on GNOME 2.32 distributed by Ubuntu.
-
Matthew over 13 years@tante that's the sort of answer I was after, yes
-
Matthew over 13 yearsthat's a great answer.
-
Matthew over 13 years@echox nice logo. hail to the thief.