LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-04-2018, 05:59 PM   #1
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Rep: Reputation: 174Reputation: 174
How does Linux remember that there is trash in the trash can?


Perhaps this question belongs in the security forum (really need a privacy forum) but I guess it will get reasonable exposure here.

I generally do not use the trash can feature. When I delete something I DELETE it. That said I sometimes accidentally trash instead of delete or perhaps an application sends to trash when asked to delete. Bottom line, I see that there is trash in the trash can icon (CentOS 7.5 with Mate desktop). Easy enough to empty trash. Except...

Recently I noticed that the trash can icon was indicating something in trash. I opened trash but nothing was there. Eventually I figured out that I must have deleted something on a removable storage device and then unmounted/removed the device before doing the empty trash drill. I reinserted the device (flash drive) and the "trashed" items appeared in Trash.

My research has found that trash is supposed to be "stored" in ~/.local/share/Trash. I looked in said directory and it subdirectories and found nothing with or without the removable device mounted. Further investigation found the directory /.Trash-1000 on the file system of the removable device. The trashed files were there. This at least relieved my concern that meta-data from a removable device might be leaked to the fllesystem of the hard drive in the PC. Still I am wondering...

How does the OS know that a removable device is floating around the universe with "trashed" files on it?

TIA,

Ken
 
Old 07-04-2018, 06:24 PM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Ken,
I don't know the answer...but wanted to point out that the Trash is not a function of the OS, but rather of the desktop (you said Mate, yes?) A machine without a desktop doesn't have a Trash.

I'd suspect some kind of global thing to turn on that flag, but I don't really know.

Unlike Windows, Linux pretty effectively separates the Desktop Environment from the OS. For example, I'm running CentOS 7.4, but am using the Cinnamon desktop.
 
Old 07-04-2018, 07:10 PM   #3
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Original Poster
Rep: Reputation: 174Reputation: 174
Thanks scasey,

You are correct. I did not mean to say OS but I was tired of typing and OS was shorter that desktop environment

As I wrote the original post I was still doing some searching. My initial concern was that the meta-data re. where does this deleted belong (where should it be restored to) might be stored on the main file system. This would not be a good thing if the location was on an encrypted file system which had been locked or an encrypted device which had been removed - if that device contained sensitive information. It appears that that is not the case so it has sort of devolved into a curiosity.

Thanks again,

Ken
 
Old 07-04-2018, 09:05 PM   #4
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,328
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
On my computer, "Trash" is a directory located in ~/.local/share. The system need only check for the presence of a file or files in that location.

Code:
$ ls ~/.local/share/Trash
files  info  metadata

Last edited by frankbell; 07-04-2018 at 09:07 PM.
 
Old 07-05-2018, 05:09 AM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
even if you delete a file properly, its contents can almost always still be recovered, so the only real security would come from using something like shred.

about Trash directories on removable media, this topic has been discussed dozens of times during the last 15 years or so, please do some research.
 
Old 07-05-2018, 07:26 AM   #6
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Original Poster
Rep: Reputation: 174Reputation: 174
Thanks frankbell,

I have a similar structure on /home/ken/.local/share/Trash. In my case the directories are expunged, files and info. It seems to handle files ONLY on the /home file system (which is on its own partition). Actually I guess it only handles MY files. Each other partition or file system has a directory /.Trash-000 which handles trashed files for that particular file system.

Thanks ondoho,

My question was not about the ability to recover a "deleted" file. I do on occasion use shred. Generally I think ahead and prepare an encrypted file system or Vera Cryot type container before writing a sensitive file.

I have gotten to the bottom of my issue. I trashed a file on the flash drive on my CentOS 7.5 Mate machine. I ejected it and the trash can stayed "full." I placed the flash drive in an Ubuntu Mate 18.04 machine. The trash can icon changed from empty to full. The trashed file appeared in the trash directory when I opened it in Caja. When I went to eject the flash drive I was asked if I wished to empty trash before ejecting the device. CentOS did NOT do so. That is the source of my confusion.

I guess I need to file a bug - I guess with epel as that is where I installed the Mate desktop environment from. It does not seem to be a Mate specific issue as it works on Ubuntu.

Thanks again,

Ken
 
Old 07-05-2018, 11:58 AM   #7
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,947

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
It's quite safe to delete the Trash folder. This will give you your storage back.
It will be automatically re-created next time you delete a file via the GUI.
 
Old 07-05-2018, 12:53 PM   #8
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Original Poster
Rep: Reputation: 174Reputation: 174
Thanks JeremyBoden,

I am not concerned with any lost space. The point is that the trash can icon is implying that there are some trashed but undeleted files on my computer. In fact they are on the SD card which is back in my DSLR camera. As I described previously Ubuntu handles this "properly." I need to try Fedora + Mate and CentOS + Gnome3 to try and narrow down who is at fault in my situation.

Ken
 
Old 07-05-2018, 01:17 PM   #9
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Have you checked your home or trash directories (on the host system, not the flash drive) for a directory named along the lines of .Trash-uid?

The XDG spec: https://specifications.freedesktop.o...hspec-1.0.html

https://specifications.freedesktop.o...ec-latest.html
 
Old 07-05-2018, 02:41 PM   #10
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Original Poster
Rep: Reputation: 174Reputation: 174
Thanks hydrurga,

As I stated earlier I found my "home" trash at: /user/ken/.local/share/Trash

If I "delete" a file in my home directory tree it disappears into /user/ken/.local/share/Trash/files. I have a couple of other filesystems. /quitelarge and /xtra. Each is contained on a different drive. At the root of each filesystem I find a structure /.Trash-1000 containing expunged, files and info subdirectories. 1000 is my user ID. If I "delete" a file on the /quitelarge filesystem it disappears to the .Trash-1000/files directory on the quitelarge filesystem. This makes sense as there is no reason to copy the deleted file to the trash folder on the fllesystem where my home resides. All of this seems to be working OK.

Ken
 
Old 07-05-2018, 03:17 PM   #11
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,947

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
Incidentally, I've got the same kind of set-up with a bigstuff & video (separate partitions).

bigstuff just tells me (words to the effect) that it can't preserve an attempted deletion, do I want do delete anyway.
But video works fine and moves the file into its Trash.

I don't know why this is so - I'm guessing it's probably a permissions/ownership thing?
This is not a problem for me, so I've never bothered about it.
 
Old 07-05-2018, 04:25 PM   #12
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by taylorkh View Post
I guess I need to file a bug
before you do that, please do some research as per my statement in post #6.
honestly, this topic has been chewed to death over the years.
 
Old 07-05-2018, 06:59 PM   #13
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Original Poster
Rep: Reputation: 174Reputation: 174
A search for "Trash directories on removable media" on LinuxQuestions.org returned two threads. This one and another where the user wanted to prevent Ubuntu from creating one. A www wide search brought up a lot of hits about how does trash work, not work, I want it, I don't want it etc. That is NOT the issue. I understand how the trash folder process works. My system properly creates various trash directory structures per the XDG specs referenced (as best I can determine.)

The issue is that CentOS/Mate "remembers" trash is present even when the file system containing the Trash folder is removed and/or unmounted from the system. This included removable media, encrypted "containers" (e.g. VeraCrypt) and LUKS encrypted Linux file systems. I say it remembers in that the trash icon shows trash present even though it cannot be accessed nor deleted. Ubumtu Mate seems to handle it in a more rational manner at least as far as removable devices. I have not tried an encrypted container or file system on Ubuntu.

I did determine that a logout/login will cause this remembrance to clear. It sure sounds like a bug in whatever manages the state of the trash icon to me.

Ken
 
1 members found this post helpful.
Old 07-05-2018, 10:03 PM   #14
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,328
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
If the option is available, I set file managers to bypass Trash and just make the file go away. If I blow away the wrong file, it's on me.

In KDE's Konqueror in file manager mode, "direct delete" is a configuration option (I forget the exact wording). In KDE's Dolphin, you can set "Trash" to delete files from Trash after [unit] time. I don't use other file managers enough to know whether they offer such options, but it might be worth exploring them.
 
Old 07-06-2018, 06:58 AM   #15
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 2,127

Original Poster
Rep: Reputation: 174Reputation: 174
Thanks again frankbell,

I generally use gnome-commander. Delete means DELETE. I also have the option set in Caja (Mate fork of Nautilus) to bypass trash. Where I generally run across the issue is with Eye of Mate (Eye of Gnome) when culling photos. I see one I don't like and press the delete key forgetting that it does not "delete."

Ken
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trash is Full. Empty Trash before moving more files/folders to Trash. wdarledge Slackware 45 12-13-2017 03:53 PM
Lost disk space after deleting files, trash, hidden trash, etc. themacguy Ubuntu 7 06-06-2012 02:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration