Try:
cd ~
mkdir .local/share/Trash
mkdir .local/share/Trash/expunged
mkdir .local/share/Trash/files
mkdir .local/share/Trash/info
chmod -R 700 .local/share/Trash
... and then restart nautilus with nautilus -q
. I am not sure it will work, it is just recreating the structure I have with an empty trash; you can safely ignore error about existing directory.
Notice, no sudo
here. The trash is yours, should be manageable without superuser privileges; as a general rule, you should never use sudo
to manage file in your home directory --- unless you have to fix previous sudo
usage, that is.
If you have messed with superuser in this dirs, you may need to fix the ownership...
sudo chown -R myuser .local/share/Trash
Where myuser
is your normal user, of course.
And BTW, the "not erasable file" was probably a file in another partition.
After looking at Nautilus's source code and Michael Stumpfl's answer it becomes clear that trash folder creation, is something hard-coded in Nautilus's source code itself and is part of how libgio
works - the library behind file manipulations in Gtk/GNOME applications. Therefore disabling such behavior is currently not possible without recompiling either the file manager itself or altering source code of the library ( which I wouldn't recommend doing, since other applications rely on it, so changes may affect other applications' behavior ).
Probably the best solution is to propose a feature request to Nautilus developers and wait until it is fixed. One could also resort to permanent deletion of files via Shift+Delete short cut or using command-line utilities such as mv
(move to user's trash folder on /
filesystem) or rm
. Otherwise - switch to using different file manager for the time being.
Best Answer
Pre-Author's Note:
Read through all of this post until you find a satisfactory solution. If not, add a comment telling me I am the worst wannabe in the world.
;)
Also, the Trash is not what is taking up all of your space. You do not have a Trash Can created, below are instructions of how to make one. In the terminal, when you delete something it is gone forever, except if you use a recovery program likeforemost
(see below.)The Location of the Trash Folder
The trash folder is located at
/home/username/.local/share/Trash/
. This folder may not be there because of you running from terminal, but keep reading! It is only created once a file has been moved there with a GUI (I'm not 100% about this part, but my LXDE setup only created it when I moved a file to there with the file manager).Explanation:
Due to @Zacharee1, I have realized the true nature of your question. Thank you for that @Zacharee1. So, a Trash Folder doesn't exist in terminal-land, so you have to either create your own or be OK with having the danger of losing important files forever. Of course, that means that the space usage is not caused by that.
If you have a Trash Folder Already Created:
The items inside the Trash folder will be inside another folder, the
items
folder. Now, if you want to clear this use two separate commands.If You Just Want To Restore Some Files:
Take a look into the forensics program
foremost
. You can download withLook at online instructions for using it, use the
man
page or look below at my extremely limited understanding of how this works. Let me stress that, I just found this and am not knowledgeable in this area, so do not think everything I say is true. On HowToForge (https://www.howtoforge.com/recover-deleted-files-with-foremost) it tells you to run(Obviously) Replace filetype with the type of file you need to recover. For example, if I wanted to recover
pdf
s I would doYou will find what is recovered in a folder in the directory you are in called
output
. If you want to do it multiple times in the same directory, doThe extra -T stands for timestamp so the separate outputs won't mess eachother up. For a better understanding of
foremost
, check out the link provided or do your own research.enter code here
If You Don't Have a Trash Folder Created (And You Want One):
This one is probably you! So, you might have to try two separate things.
The first, and probably most unappealing, is to figuratively make your own Trash folder, set up a timer for it and a system for the files inside to be deleted. You can do this by adding a script to your
crontab
, which has a timer of 1 month. When the timer gets high enough, BAM,rm /path/to/trash/*
If you Don't Want to Do It Yourself:
Alright soldier! There are a couple of things you need to know. The
crontab
. A useful tool which lets you run scripts and commands at startup. We probably will be using this. There is a big flaw to the idea that I just proposed. The timer will it only run if your computer is on. AHA, I've got a (slightly) better idea!The Slightly Better Idea!
Alright, this will involve a python script and a
.txt
! Hurray! You will need an emptytxt
file in the same folder as this one calledgarbage.txt
. So, basically, these are the contents:Now then, add this script to the
crontab
. I'll assume for benefits of the reader that you don't know how to do this. So, create a bash script in the same directory astrash.py
. Call ittrashshell.sh
. In it write:Save that, then type in the command
crontab -e
to the terminal. Select the terminal editor nano and then writeHope this helped!
Optional: An Easy Delete!
Put this:
into your .profile or your .bashrc (Do bashrc if it exists). This will all you to move items to trash with
trasher itemname
. For example,trasher new.txt
A probably False Idea!
Try recreating a Trash folder in the spots it would be, like the
Trash
folder, theexpunged
folder, thefiles
folder, and theinfo
folder. Wait 30 days. This probably won't work!!!Author's Note:
Do not copy and paste the code I wrote. The indentation is almost 100% messed up, because cannot do formatting on Stack Overflow! Some one teach me please!!! If you made your own trash folder and you're feeling adventurous you can change some stuff up a bit, like the length of the timer.