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/*

Incoming search terms:

Related posts

67 thoughts on “Empty Ubuntu Gnome Trash from the Command Line

  1. Thanks a lot ayenack! I am using 8.04 hardy heron and the command: sudo rm -rf ~/.local/share/Trash/files/*
    worked like a charm! A word of recommendation to those who can’t get it working. Simply copy and paste. Yeah, it’s a lazy thing to do, but if typing it ain’t cutting it, then it’s an operator error, not a computer error. Keep that in mind when it seems the command line isn’t cooperating.

    [Reply]

  2. I too had problems deleting files that I had copied from a data cd. some times was able to change permissions till this last lot of trash on my 8.04v. command worked! my first success at command line! great for the confidence.
    tis a wonderful website!

    [Reply]

  3. bad a$$ i had like 200 mp3s that i couldnt get rid of
    sudo rm -rf ~/.local/share/Trash/files/*

    that worked on ubuntu 2.0
    thanks

    [Reply]

  4. Emil: “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.”

    Guess what Emil? IT DOES EXIST. Take a look at the lower-right hand corner of the screen – that’s where the Trash icon is by default. Left clicking opens it, and you can either right-click and choose empty trash, or hit the “Empty Trash” button while viewing the files.

    We just find the terminal faster, generally.

    Oh, and as for my problem earlier, I now know what was wrong – link makes hardlinks only, while nautilus makes softlinks. Here’s the command you need:

    ln -s .local/share/Trash/ .Trash

    [Reply]

  5. Using Andrea Francia trash-cli package is very helpful :

    sudo empty-trash empty your trash with any permission problem whereas

    sudo su
    empty-trash

    empties **root** trash !

    [Reply]

  6. Instead of using sudo rm -rf ~/.local/share/Trash/files/* use the full path if you still have issues.

    user@machine:~$ sudo rm -rf /home//.local/share/Trash/files/*

    Replace by your own username, of course.

    [Reply]

  7. Oops! <user> was removed from the command.

    It’s:

    user@machine:~$ sudo rm -rf /home/<user>/.local/share/Trash/files/*

    [Reply]

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

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

    [Reply]

  9. All I did was restored the folder and reset the permissions and then I was able to empty my trash can after I deleted the folder again.

    [Reply]

  10. Last time I have emptied my trash the trash applet said it was 4 elements left in the trash. Nautilus showed the trash as empty, and also there was nothing left in ~/.local/share/Trash/files and info directories.

    Removing trash applet and then putiing it back onto the taskbar fixed the problem. Weird. This is on Intrepid 8.10 with Gnome 2.24.1

    Hope this helps. Cannot file a bug report since I don´t know how to reproduce.

    [Reply]

  11. Thanks Lex. Nothing else worked for me either except for removing the Trash applet and then adding it back to the panel.

    [Reply]

  12. The following works on Ubuntu Hardy Heron 8.04
    1. open terminal
    2. type gksudo dbus-launch nautilus
    3. hit enter
    4. navigate to /home/USERNAME/.local/share/Trash/files
    5. Delete whatever you want

    [Reply]

  13. Good to know this. Here’s the problem it solves (partially) for me:

    I deleted files from my desktop. Unfortunately the permissions of the folders/files was read only. Trash would not allow me to delete them permanently or change permissions. Copying back to the desktop and changing permissions wouldn’t work because that would still leave copies in Trash that couldn’t be manipulated.

    sudo rm -rf ~/.local/share/Trash/files/* deleted most of them. It left one folder – not sure why; i’ll have to look into it later. Thanks.

    [Reply]

  14. It could be that the troublesome item stuck in the Trash is not in your home directory, but on another hard disk or partition. In that case, use the command line to delete them after changing to that directory. For example:
    # cd /media/ExternalDisk/.Trash-1000/files
    # rm -rf *
    Be very careful you are in that Trash directory before using the powerful delete command as Root.

    [Reply]

  15. I had a similar problem… tried emptying the trash with the icon and it would say emptying and you could see the progress, but when you went in the folder everything was still there. Tried all the commands and same thing. The only way i got it to work was to cntl-alt F6 and log into another session on the command line and physically go to the folder and delete stuff using the rm -rf commmand…. very strange. After i did that, when i went back to my xwindows session i was able to empty the trash as normal again…..

    [Reply]

  16. I had this issue where I had been deleting files using the root authority on 9.04. When emptying the trash I would get an error that not all files can be displayed but the mouse pointer would spin for minutes and nothing would be displayed.

    Thierry B.’s sugguestion worked for me.
    apt-get install trash-cli
    empty-trash

    Funny thing is I do a lot of VM work on this box, and it’s been a while since I really looked at my disk utilization. this utility cleared the 20 GB of files I knew about and it cleared another 30 GB of stuff I didn’t know was still on the drives.

    THIS IS WHY LINUX Fails to penetrate the windows desktop world. We can’t even have a fully functional trash bin on the Desktop?

    SIGH. I’ll keep believing!

    [Reply]

  17. I love linux and these little quirks are nothing to me…. so many positives compared to the negatives of windows…. Do I have to list them? :)

    [Reply]

  18. This is how I managed to delete the troublesome folder.

    In the terminal I typed
    # locate brid

    the following two lines where amongst the output

    /data-l1/.Trash-1000/files/brid
    /data-l1/.Trash-1000/info/brid.trashinfo

    Then I deleted the as follows

    # rm -rf /data-l1/.Trash-1000/files/*
    and
    # rm -rf /data-l1/.Trash-1000/info/*

    This emptied my Trash
    Good luck

    [Reply]

  19. Folks, you need to delete the ~/.local/share/Trash/info/* files too.

    I aliased it:

    alias emptytrash=’rm -fr ~/.local/share/Trash/files/* ~/.local/share/Trash/info/*’

    [Reply]

  20. I find this really useful when working without X running. Basically, enter the following alias into your .bashrc file;

    alias ebin=’rm -rf ~/.local/share/Trash/files/*’

    Replace ebin with whatever command you want to use to carry out the operation and all you have to do is issue that command whenever you want to empty the trash.

    [Reply]

  21. Trash shows as having items inside .. “2 items in Trash”
    And it’s not getting emptied. Tried all the methods.

    [Reply]

  22. I wasn’t able to delete the plethora of files that had accumulated in my root trash until I used

    sudo su, first and then ran
    sudo rm -rf ~/.local/share/Trash/files/*

    Thanks for this forum discussion, I had no idea how to get rid of the files before. Yeah, free space!

    [Reply]

  23. Thank you LadySol! I din’t think about nesting the command in su mode. Nothing else worked…well didn’t try trash-cli.

    [Reply]

Leave a comment

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