-5

The trash spec tells me that the Trash directory is here: $XDG_DATA_HOME/Trash

Looking at my environment variables on my Linux Mint system, I find a bunch of XDG stuff, but no XDG_DATA_HOME

I've done some looking, but so far I have not been able to locate the Trash directory. Where is it?

Luiz Berti
  • 1,421
  • 1
  • 15
  • 24
Chuck Pergiel
  • 151
  • 2
  • 14
  • 2
    [Reading a reference always helps](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables). – Some programmer dude Jun 21 '16 at 01:20
  • Usually it's under `~/.Trash` or `~/.local/share/Trash`, this is literally one of those questions that is a quick Google search away – Luiz Berti Jun 21 '16 at 01:20
  • If you're using a file manager gui, perhaps you need to enable `Show Hidden Files and Hidden Directories` to see .Trash, et al. – chickity china chinese chicken Jun 21 '16 at 01:44
  • Found ~/.local/share/Trash on my system. How did you know that? And how are you supposed to find it from inside a program? None of the environment variables contain .local. Lots of 'local' and 'share' but no '.local', and certainly no 'Trash'. – Chuck Pergiel Jun 21 '16 at 03:16

2 Answers2

3

your home trash directory MUST be available and defined.

Usually it's under ~/.Trash or ~/.local/share/Trash as default

you can echo $XDG_DATA_HOME to display it, if you get nothing, you can set it by yourself.

XDG_DATA_HOME=/usr/local/share/
export XDG_DATA_HOME

and

XDG_DATA_DIRS=/usr/local/share/
export XDG_DATA_DIRS

for details see setting XDG_DATA_DIRS and XDG_DATA_HOME

and I recommend that you make trash-cli as an alternative for the rm, it's the command line interface to FreeDesktop.org Trash,

see https://pypi.python.org/pypi/trash-cli/0.12.9.14 https://github.com/andreafrancia/trash-cli

Community
  • 1
  • 1
gatieme
  • 105
  • 9
1

your home trash directory MUST be available and defined. Usually it's under ~/.Trash or ~/.local/share/Trash as default you can echo $XDG_DATA_HOME to display it, if you get nothing, you can set >it by yourself.

First it is impossible to set something you cannot find in the first place. Secondly env | grep XDG does not return any variable XDG_DATA_HOME, so that provided no help whatsoever. Thirdly, Google search on e.g. "where is linux Trash folder stored" does indeed turn up results -- namely this page and others like it. Search engines are source referrers, not source providers. If someone hasn't already posted it somewhere, it won't show in Google or anywhere else. Suggesting a Google search as an answer is not helpful.

So indeed, find / -iname trash will find it (recommend adding 2>/dev/null to eliminate all errors that will occur for inaccessible files), but novices have a lot of trouble with find's syntax.

So yes, it is usually ~/.Trash or ~/.local/share/Trash. As for trash-cli, yes very helpful, but the correct instructions for it are:

sudo apt install trash-cli -y
alias rm=trash-put
alias rm >> ~/.bashrc  ( or >> ~/.bash_aliases)

Now, I would like to know, if I set XDG_DATA_HOME to /tmp, will trashing a file move to /tmp instead? The concept of a Trash folder is great, but I'd like a little more sophistication like an Archive folder where I can archive-put little used files that I still want to keep but keep out of my main folder stash to eliminate clutter. I'm no linux novice, but I do have limited time--so that is why we collaborate--I save you time, you save me time!! I hope. Less is more, more or less.

B.A. C.S.
  • 19
  • 3