How ToLinuxOperating SystemsUbuntu

[How To] Empty Trash in Ubuntu from command line

Ubuntu is one of the widely used desktop operating system in the open source world. Like Recycle Bin in Windows, Ubuntu has Trash to store the deleted files and retrieve them anytime.

Sometimes, deleting all the contents from Trash may take a longer time or it may hang up your system. In this case, deleting single file will be a tedious job. Instead of using GUI, all the contents in the Trash directory can be deleted in one shot from command line/shell/terminal.

Below are the steps to delete all the contents from Trash using command line/shell/terminal:

1) Open terminal and navigate to your home directory, typically /home/username.

2) Go to the Trash directory present at .local/share/Trash

cd .local/share/Trash/

The complete Trash directory path is $HOME/.local/share/Trash

3) From the list of folders, go the folder with name as files.

cd files

The above folder contains all of your Trash files.

4) Delete all the files using following command:

rm -rf *

Be patient, since it may take sometime to delete the files depending upon Trash size.

Note: This method will delete Trash contents only of the specific user. To delete Trash of another user, login with that user and repeat the procedure.

Related Articles

2 Comments

  1. Thanks for the directory information.
    I found out that one folder had elevated privileges.
    So I deleted all files in all folders under trash directory as administrator.
    Now I can open Trash again and it works fine.
    Thanks.

  2. Hey! This is really all nice and informational but if you are looking for a cool no-brainer way to take care of trash files in Ubuntu , then just install the "autothrash" package. It has all you need and it doesn't require you to remember complex command line arguments or obscure folder paths.

    Quote:
    "
    NAME

    autotrash -- program to automatically purge old files from the
    FreeDesktop.org trash

    SYNOPSIS

    autotrash [-d purge_n_days_old]

    autotrash [--delete number_of_megabytes_to_purge]

    autotrash [--keep-free number_of_megabytes_to_free]

    "

    See man page:
    http://manpages.ubuntu.com/manpages/natty/man1/autotrash.1.html

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button