Linux: Move File to Trash by Command

By Xah Lee. Date: . Last updated: .

What is the Linux command to move file to trash?

gvfs-trash filepath

This works in all {Ubuntu, Gnome, Xfce, KDE}.

[see Linux: How to Switch to LXDE, Xfce]

Where is the trash directory?

On your local file system.
If you are root, on your local file system.
On a USB drive.

It is safe to delete the trash directory.

rm -r ~/.local/share/Trash

How Does Linux Trash Work?

In the trash dir, there are 3 dirs:

Deleted files but for some reason unable to delete. (this is not in spec, as of version 0.7.)
Contains the actual trashed files.
Contains text file that has info about trashed file.

For example, if you have a file at /home/joe/Downloads/cat.jpg and you deleted to trash. Then, you'll have:

and the file cat.jpg.trashinfo will have content like this:

[Trash Info]


[The Trash specification By Mikhail Ramendik. At]