Empty Ubuntu Gnome Trash from the Command Line

Sponsored Link
Ubuntu has a trash can/recycle bin feature similar to windows. The difference with Ubuntu is that you can empty the trash from the command line.

First you need to open your terminal and type the following command

rm -rf ~/.Trash/*

You may also like...

67 Responses

  1. Richard Steelreath says:

    Running the command logged in as root rm -rf ~/.Trash/* did not work for me. When I try to empty Trash on the desktop I get error messages that I don’t have permissions to modify the files parent folders, so how can I
    delete what is in Trash?

  2. Oswald says:

    To Richard
    You probably have files there that can only be erased if you have root privileges.
    So, try this code instead:
    sudo rm -rf ~/.Trash/*

  3. George says:

    I have a small question regardind the trash can. Is it possible to limit the amount of space that the trash can use? Something like 10% from each partition, just like in Windows.

  4. Eruc says:


    . Do you have the same command for KDE ?

    (I’m using Krusader (KDE prog) under Gnome and of course the two environment are incompatible : two sounds servers lauching, two directory for Trash, etc, etc.. What a joke !)

    . Wouldn’t it be possible to make two symbolics links (KDE and GNome trash directory) pointing to the same directory ?

  5. twoaday says:

    Another thing that you can try is to use the sudo -i command and log in as the super user and the navigate in terminal to the trash folder “/home/username/.Trash” and then issue the “rm -Rf filename” command if it is a folder full of stuff that you just can’t get to go away.

  6. Dan says:

    If you’re logged in as root, using the ~ shortcut will point to root’s home dir, not yours. Instead of ~/.Trash use /home/your user name here/.Trash

    Running the command logged in as root rm -rf ~/.Trash/* did not work for me.

  7. Brett says:

    Thats not where things are stored anymore in 8.04… Its now in /home//.local/share/Trash and its broken up into info and files.

  8. ayenack says:

    Just a quick note for anyone using Ubuntu 8.04 Use this in terminal instead.

    sudo rm -rf ~/.local/share/Trash/files/*

    That should do it.

  9. Patrick says:

    Thanks! That helped me remove a file that the trash can wouldn’t delete for some reason!

  10. Will says:

    I’m having a strange problem. There’s a directory that won’t empty from trash because some enclosed files don’t give me permission to delete them, however they’re not listed anywhere in /.local/share/Trash/files/* so even if I use the sudo rm -rf ~/.local/share/Trash/files/* command in the Terminal it still remains.

    Any ideas on what to do?

  11. 92ny says:

    Thanks a lot Ayenack, worked for me too.

  12. Dave says:

    A possibly naive questions…

    I had the same problem as others here — trash that wouldn’t empty because I didn’t have permissions to do so. I looked for a .Trash folder in my home directory and there was none. I found the offending files at /.local/share/Trash/files/* and deleted them, which took care of the problem.

    My question: Where is the trash supposed to be? I thought the former. Why was it the latter? Is it a Gnome thing? A Nautilus thing? (I’m using Ubuntu 8.04 here.)

  13. Alaa Salman says:

    It depends on the Gnome version, hence the Ubuntu version. Gnome 2.22 which ships with Ubuntu 8.04 has the trash in the .local folder, while the Gnome releases before it have it in the $HOME folder. If i am not mistaken, this change was implemented along with the new GVFS in Gnome.

  14. Derka says:

    I have emptied most of the items in the trash can in Ubuntu 8.04 using the command, sudo rm -rf ~/.local/share/Trash/files/*; however, I am unable to delete one item namely because the “device or resource is unavailable of busy”. How would I be able to delete this file, then?

    I would be gracious for any help, thank you.

  15. Derka says:

    Sorry, I meant to say that the output when I try to delete this file is “device or resource is unavailable or busy”.

  16. Izkata says:

    izkata@Izein:~$ link .local/share/Trash .Trash/
    link: cannot create link `.Trash/’ to `.local/share/Trash’: No such file or directory
    izkata@Izein:~$ link .local/share/Trash .Trash
    link: cannot create link `.Trash’ to `.local/share/Trash’: Operation not permitted
    izkata@Izein:~$ link .local/share/Trash/ .Trash
    link: cannot create link `.Trash’ to `.local/share/Trash/’: Operation not permitted
    izkata@Izein:~$ link .local/share/Trash/ .Trash/
    link: cannot create link `.Trash/’ to `.local/share/Trash/’: No such file or directory

    And tips? I can make it just fine by opening nautilus, right-clicking on Trash, choosing “make link”, and moving it to my home directory… Still annoying that it wouldn’t work through the command line, though.

  17. Derka says:

    Just shut up, Izkata, no one cares about ur problems! God, can’t u just solve it on ur own, u stupid retard?! Some people are just so stupid!

  18. Danno says:

    Uhh guys? What’s stopping that wildcard from deleting everything? Won’t it follow the .. directories back into your home folder?

  19. beerfan says:

    Deleting only the files in ~/.local/share/Trash/files will leave metadata about deleted files in ~/.local/share/Trash/info

    To delete everything (on Ubuntu 8.04+) you can use the following command. This will delete all files, but exclude directories.

    sudo find ~/.local/share/Trash -type f -exec rm ‘{}’ \;

  20. m4r10l4 says:

    better use:
    sudo rm -rf ~/.local/share/Trash/*

    all in one

  21. Akoi Meexx says:

    Will: I had a similar problem with a read-only filesystem error. Turned out to be a flash drive I had plugged into usb, with USB Slax in a trash folder. For some reason it kept flipping to read only and i had to take it to a Windows system to get rid of them. Any external media plugged in?

  22. The trash-cli software provide (among others) a specific command for empty the trash: empty-trash.
    It take care of all FreeDesktop Spec trash directories: $topdir/.Trash/$uid, $topdir/.Trash-$uid, ~/.local/share/Trash.

  23. Alex.... says:

    to delete all files in ubuntu 8.04.1 Hardy heron you have to to 2 things(it worked for me i’ve tried what was posted here but it dint work for me):
    1.cd /home/youre login name/.local/share/Trash/files
    2.sudo rm -rf *

    Mention: youre login name=the name you type at the login screen when you start ubuntu.

    Thats all it deletes all files from trash

  24. emil says:

    Such a simple thing poses problems to so many people!
    Conclusion: stupid users? NO.
    It’s a usability thing. It is much better to have it Windows style in this case: a visual thing, right-click + empty.
    Why better? Because it is the OS’ responsibility to know where the Trashed files are. Second, the OS will handle the permission issues, by simply not deleting what you don’t own (?) or smth.

    Last note: think about this: why are you using a trash can anyway? so you don’t do accidental deletes, right? well, be careful when removing the trash then!

  25. Derka says:

    Guys, instead of posting all of your problems, just try and help others with their own problems first, and maybe your problems will be solved in the process. Just an idea 🙂

    BTW: Sorry, Itzaka, ur not stupid.

  26. Derka says:

    I have Ubuntu 8.04 installed (but I haven’t installed software updates yet), and when I go to /home/derka/.local/share, there is no trash folder. Do you guys know where the trash folder is in Ubuntu 8.04.1 LTS?

  27. Andrei says:

    Hello.I have Ubuntu 8.04 from April 2008.Not updated to 8.04.1 LTS [except openoffice,firefox which I updated from Synaptec] because of some hardware problems.Did you mark from Computer [View menu] or Krusader / Gnome Commander[exactely like Total Commander from Windows] to show you hidden files and folders? Try this,and,also look in the admin [root] folder if he has the trash folder /root/.local/share/Trash.you can also write me at : [email protected] .Good Luck! 🙂

  28. Faceless says:

    Faced with an extra problem, while trying to use the given commands I seemingly erased /Trash/ from /home/username/.local/share/Trash/ (the /Trash/ thing can not be found anymore using MC)
    But what is bothering a lot is that from the desktop where the trashbin can still be found, I can still not delete the contents. (50+ GB) Not on user or root account whether or not using the superuser command.

    Any suggestions left ?


  29. xopherh says:

    simply navigate using the terminal to
    and do a list all with details
    [code]ls -al[/code]
    and then manually delete (remove) the listing of the file
    [code]sudo rm -rf filename.file[/code]

    and since you’re down there you might as well look in the other trash folder and do the same
    and you could also do the same for root as well.

  30. Faceless says:


    Thanks for replying but your suggestion doesn’t help me. As my terminal says the following:

    root@user-laptop:/home/username/.local/share/Trash/files# ls -al
    total 8
    drwx—— 2 username username 4096 2008-09-27 23:20 .
    drwx—— 4 username username 4096 2008-09-24 19:32 ..

    Btw it says the same at the …/info/ one, which thus leaves me without any filenames manually remove anything.
    Maybe if this part could be solved your suggestion would work, but now I seem unable to try. Thanks, at least you gave me hope that I might be able to solve this at least.


Leave a Reply

Your email address will not be published. Required fields are marked *