20

What is the shell command to empty the garbage bin under Linux?

Gareth
  • 19,080
Rob
  • 201

4 Answers4

21

Except for the ~/.local/share/Trash trash files for other file systems may be stored in <mount-point>/.Trash-$(id -u) directories. If your're running ubuntu there is a helper package to clean all locations

sudo aptitude install trash-cli

To clean the trash in all locations just run:

empty-trash

It should work with any linux desktop environment compliant with FreeDesktop.org Trash Specification. On newer versions, the command may be:

trash-empty
10
rm -rf ~/.local/share/Trash/files

If not under .local/share, it may be under ~/.Trash

Linker3000
  • 28,240
3

In case you would like to empty the trash of the currently logged in user:

rm -rf ~/.local/share/Trash/files/*
Gareth
  • 19,080
udo
  • 8,061
0

After installing the OS if you haven't deleted/moved anything to Trash from GUI, then the Trash folder under user's directory wont get created at all. So if you search for Trash directory from command line you wont find. Now lets say you move/delete a file into Trash from GUI, that's when the directory Trash gets created and is accessible from command-line. If you restore the file or delete the file permanently either from GUI or from command line the Trash folder still stays and is accessible from GUI and command-line.

command line Trash directory:- "/root/.local/share/Trash" under Trash you got two directories again, one with "files" and one with "info". files :- actual data info :- metadata of the data

Checked this on Centos 6.8

Edit :- the files in the thrash can be either deleted from GUI or by getting into /root/.local/share/Trash/files and remove everything

Ashwin
  • 101