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. Most Useful GUI Apps
  2. Set Default App
  3. Shell Commands for GUI Apps
  4. Image Viewers
  5. Music Players
  6. Move File to Trash by Command
  7. X11 Selection and Clipboard
  8. How to Switch to LXDE, Xfce
  9. LXDE Keyboard Shortcuts
  10. LXDE/Openbox, Change Keyboard Shortcuts
  11. LXDE Set Key Repeat Rate
  12. LXDE/OpenBox, Disable Mouse Scroll Wheel Hide Window
  13. Xfce Keyboard Shortcuts
  14. Xfce Good Themes
  15. xmonad Keybinding
  16. How to Restart X11
  17. Why Tiling Window Manager Sucks

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