7

I did a stupid thing. I was having issues with certain files in my trash that my system was not allowing my to delete, meaning I could no longer empty my trash. These were not super important files, just theme folders I was creating and ditching. After getting frustrated, I googled it and was led to executing this script sudo rm -rf ~/.local/share/Trash/*which looks as though it totally removed my trash...completely and now I can no longer add items to it. How can I restore my trash once again? I know it's probably as simple as re-creating the file, but I'm unsure of the terminal language to do this.

Thanks in advance.

TL;DR I removed my trash directory with sudo rm -rf ~/.local/share/Trash/*and need help getting it back/making a new one.

6

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.

| improve this answer | |
  • 1
    No need to give ~ argument to cd — it defaults to home if run without arguments. – Ruslan Oct 16 '14 at 17:24
  • @Ruslan you are right --- and probably mkdir -m 700 -p ~/.local/share/Trash/{expunged,files,info} would work in most shells, but call it defensive shell commanding ;-) – Rmano Oct 16 '14 at 19:41
  • Unfortunately, this did not work. I was repeatedly told in terminal cannot create directory bc it already exists. When I navigate to .local/share/trash I can see the folders expunger, files and info. Files ans info have root permissions so I think that's the problem. How can I change this? – gastronomin Oct 16 '14 at 21:59
  • @Rmano mkdir -p ~/.local/share/Trash && cd ~/.local/share/Trash && mkdir expunged files info && chmod -R 700 . – Blacklight Shining Oct 17 '14 at 2:11
  • @gastronomin, I edited the answer. Hope it works... – Rmano Oct 17 '14 at 7:13
0

I had a similar problem in Ubuntu 14.04 : Thrash opened, but it was not possible to delete anything from it. I installed of the Ubuntu repository program BleachBit, I launched it, and the problem was solved.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.