19

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

20

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
1
10
rm -rf ~/.local/share/Trash/files

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

2
  • Thanks for your answer, but in .local/share/ I have just "applications" and "mime", no Trash to be found :(.
    – Rob
    Oct 15 '10 at 9:35
  • OK - have a look for /home/YOURUSERNAME/.Trash
    – Linker3000
    Oct 15 '10 at 9:39
3

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

rm -rf ~/.local/share/Trash/files/*
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

1
  • As written, this is useful supplementary information, but doesn't directly answer the question of what is the command. Can you run this answer to the finish line?
    – fixer1234
    Nov 12 '16 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.