Linux: Move File to Trash by Command

By Xah Lee. Date: . Last updated: .

What is the Linux command to put things in 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?

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:

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 , accessed on 2013-02-10 ]

Linux Desktop

  1. How to Switch to LXDE, Xfce
  2. LXDE Keyboard Shortcuts
  3. LXDE/Openbox, Change Keyboard Shortcuts
  4. LXDE Set Key Repeat Rate
  5. LXDE/OpenBox, Disable Mouse Scroll Wheel Hide Window
  6. Xfce Keyboard Shortcuts
  7. Xfce Good Themes
  8. xmonad Keybinding
  9. Why Tiling Window Manager Sucks
  10. Set Default App
  11. Shell Commands for GUI Apps
  12. Image Viewers
  13. Move File to Trash by Command

If you have a question, put $5 at patreon and message me.