It has one, but it also does not...
On one hand there is not concept of a trash bin/wastebasket on Linux, especially when dealing with the shell. rm
deletes (more or less) for good.
But on the other hand there IS a trash specification that most Desktop Environments use (like KDE and xfce), published by freedesktop. When you delete things using the GUI they will be shown in trash:///
, but the actual location is for the most part ~/.local/share/Trash
which has two sub-directories:
files
which stores the actual files
info
which contains information to the files, such as
- original filename/path
- size
There is a pitfall though: when you have another filesystem, such as a USB stick or an external HDD, the implementation of the specification is permitted to also store a trash directory in the filesystem's root directory (so if you mounted your USB in /mnt/usb/
it would be that fs' root directory) with the name Trash-XXXX
where XXXX
is your user id.
Another, slightly less common thing is that the main Trash directory is dependent on the $XDG_DATA_DIR
environment variable.
For more information on the spec: https://specifications.freedesktop.org/trash-spec/trashspec-latest.html
But can't I put things into the trash from the Shell? You may ask.
Well, yes but the only implementation that is not dependent on the desktop environment you are using, that I found, was a seemingly unmaintained python implementation with quirks like entering an infinite loop with no feedback to the user when certain operations fail. So it's not really suited for scripting purposes, maybe passable for interactive sessions.
Here is its GitHub repo: https://github.com/andreafrancia/trash-cli