380

I am not able to find trash anywhere. Can you please tell me a command or anything like that to empty the trash using terminal ?

hellodear
  • 4,833

5 Answers5

484

You can use the rm command:

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

The rm command removes (deletes) files or directories.

-f, --force     Ignore nonexistant files, and never prompt before removing.
-r, -R, --recursive     Remove directories and their contents recursively.

The trash folder is found at: $HOME/.local/share/Trash

Be careful how you use the rm command - the files aren't sent to a trash can where you can undelete them, so it's not easy to undo.

Eliah Kagan
  • 119,640
nux
  • 39,152
249

After you sudo apt install trash-cli, you can do

trash-empty

More interesting details about trash handling below and in the man page.

trash (1)            - Command line trash utility.
trash-empty (1)      - Empty for Command line trash utility.
trash-list (1)       - List trashed files.
trash-put (1)        - Command line trash utility.
trash-restore (1)    - Restore for Command line trash utility.
trash-rm (1)         - Removes files matching a pattern from the trash can
Suggon
  • 7
  • 2
jhort
  • 2,515
57

You are looking for the $XDG_DATA_HOME/Trash directory. The trash directory is defined in the "Desktop Trash Can Specification" of the freedesktop site. This variable is normally not available in the terminal windows, hence you will need for trash-empty. This command follows all the specification of the Freedesktop.org and it's intelligent enough to find out where the Trash is. You will need to install it first.

There are other tools for this, like gvfs-trash --empty which can also send items to the Trash can.

Braiam
  • 69,112
17

With trash-cli installed type trash-empty I've used this successfully to empty the trash across different drives and numerous locations.

to install trash-cli type sudo apt-get install trash-cli

Or you could use this script to do it for you.

Elder Geek
  • 36,752
5

Please note, ~/.local/share/Trash/* might not be the only location that stores the trashed files, so removing that path is not enough if you have other partitions that also have a trash folder.

If you want to empty the trash in all available partitions, you can use the following command to empty the trash:

gio trash --empty

gio is provided by glib2, which is used by most GTK-based applications, and the gio binary should be available out-of-the-box in most of the cases if you are using a desktop environment. If not, you can install it via:

apt-get install libglib2.0-bin
Gary Wang
  • 173