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/jane/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 Topic

  1. Linux: How to Switch to LXDE, Xfce
  2. Linux: LXDE Keyboard Shortcuts
  3. Linux: LXDE/Openbox, Change Keyboard Shortcuts
  4. Linux: LXDE Set Key Repeat Rate
  5. Linux: LXDE/OpenBox, Disable Mouse Scroll Wheel Hide Window
  6. Linux: Xfce Keyboard Shortcuts
  7. Linux: Xfce Good Themes
  8. Linux: xmonad Keybinding
  9. Why Tiling Window Manager Sucks (xmonad, ratpoison, dwm, …)

  1. Linux: Set Default App
  2. Linux: Shell Commands for GUI Apps
  3. Linux: Image Viewers
  4. Linux: Move File to Trash by Command

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