You can’t delete a file from your trash folder in Debian and everyone keeps telling you to look in a certain system directory, but it’s empty?—Search no longer, my friend.
I wanted to delete this file from my trash for about a year now, and I just thought it was a corrupted file system, but here is what I did (and it was really stupid).
Sometimes things on Linux just don’t work, so I always expect things to just be a bug. Maybe a little more often than I should. This file has been sitting in my trash forever now. Just recently, I set up my system from scratch, because a whole update got corrupted due to an unstable train WiFi, and I just wasn’t willing to put up with recovering everything just manually instead of just replacing the system partition and keeping my /home/ files. But in this process of re-setting my Debian 12 install, I found an old “friend”: DSC07661.JPG.
(Yes, I am absolutely telling this crap like a story. Because I can. If you don’t like it, go beg some “Linux admin”, aka computer science freshman, on StackExchange to help out your sorry a$$.)
So this f*cker hasn’t been going away for about a year, and I learned to ignore it, but there he was, in my Trash, uninvited, on my fresh install. F*ck that. You ain’t staying there. And so I investigated. Firstly, what is trash:///
?
What is trash:///?
The “file:///” type of address is actually a universal shortcut to an accumulation of locations. That is, there is not a single Trash folder, like on Windows! On a Windows system, if you “trash” something, you’ll literally move it to your trash folder (afaik, cmiiw) on your computer. Or if you’re not a moron, you press shift and delete it for good right then and there. On Linux however, “everything is a file” and everything stays a file until it dies. And every damn thing also has a file structure! Directories are files too, there is actually no reason to separate that. Directories are just files with different properties, one of them the ability to host other files.
So, let’s clear up one myth right away: There is no such thing as a “corrupt file” that you can’t delete, just because it is “corrupt” (aka missing some bytes do to a copying error or what not)… If you can’t delete that file from trash in Debian, but it exists, it is somewhere, corrupt or not. Every file, by all the holy principles of Linux (or Unix, if you’re in a cult), by definition has a location and content and is unique. So, your file must be somewhere, you’re just too dumb (or lazy, and laziness is essentially applied stupidity) to find it.
On Linux, trash:///
subsumes whatever is found in the system-wide trashes of your system. That includes all portable device trashes as well, relating to devices like:
- memory cards
- your camera
- external HDDs
In my case, the trashed file was actually not in my home trash, which is located in the directory:
~/.local/Trash
and the files trashed in there can be found in the subdir
~/.local/Trash/files
Instead, the file belongs to a directory on an NTFS-formatted external harddrive, thus has the full path of:
~/media/<username>/<external drive>/.local/Trash-1000/files/<shitfiletogetridof.extension>
As you might think seeing that number 1000, yes, there are several ones, there was a Trash-9999 before that. I have no idea what the thinking behind that is and why Debian would not create just a ./.local/Trash directory, but that rabbit hole is not part of the story here, so f*ck it.
(My best guess on the logic there would be that it has to do with the handling of trashing on different platforms, thus if somebody uses this drive on computer A/in session A and somebody else does on computer B, they might not see the same trash… even though it doesn’t make sense to me, it might make sense from a permission-control standpoint, but I honestly don’t know what the actual system architecture background is, so please enlighten me if you do!)
However, when I first wanted to delete this file for good, I assumed it was in one of those Trash directories on some external drive, but that could’ve been any of my 3 drives and 20 memory cards, so I wasn’t exactly keen on finding out by going through all of them. Thankfully though, I just got lucky on the first try, because this file would only show up when my Samsung HDD was attached, so there was the smoking gun!
I did however not really dig into the reason as to why I wasn’t able to delete the file, but reasons for that can include:
- you deleted it as root or a different user / on a different device and don’t own it
- the NTFS actually is deprecated (it’s quite possible that you can delete stuff in Windows and can’t in Linux, even though it is usually the other way around cause Windows is one weak piece of .)
- you haven’t tried turning it off and on again
Find the file’s true location to delete it
I checked out the directory and here the MF was.
By the way, when I just went to the Trash directory on my extHDD and deleted the file, this was the result. I now had two files visible in my Trash, one being a weird-ass address to the file that was deleted. Major inception, but okay.
That one however, could be deleted without issues (so lol, I can non-root-del the deleted file of the deleted file but not the deleted file, fmd).
Then I did what every sane person on a Saturday after family breakfast and a good big coffee would do and root-accessed the original folder to manually delete the file, and surprise, it was gone from my trash after that. Bye bye old friend!
This did result in an error message, but the file was gone from the trash nonetheless and hasn’t been seen ever since.
Should I add that I was still totally able to open that file and also save a copy? Which I did. No idea why I even deleted this cute picture of our skates in the first place. I can’t remember a thing. (Yes, I usually remember all the files I deleted when I see them.)
No Comments