I know about the dangers of using root access so please forego the lectures. I try to be careful and will be doubly so from now on.
I was using the file browser with root access in order to change some file permissions. During the process I deleted some files (I should say that I out them in the trash). Little did I know that the files would go to the trash as root and now I can't remove them because I don't have the permission to read them but I don't know how to access them to change the permissions because I don't know how to get into the trash as root. All I get is a message saying that:
This location could not be displayed.
Sorry, could not display all the contents of
trash:///: Operation not supported
I have searched around to try to find posts about it but I've only found outdated information about a hidden file in the root directory. That doesn't seem to apply any more so I'm stuck with a file in my trash that I can't remove and can't gain access to.
I'm using Ubuntu 14.04 64bit on an ASUS x401a laptop.
46 Answers
You will need root access to the trash to be able to delete these files - the easiest way to do this in a temporary sense, is to open a terminal window alt+ctrl+t, and enter the command
gksudo nautilus /home/your_username/.local/share/Trash
This will execute the file manager with super-user permissions and you should be able to empty the trash from here. Delete the root-owned file.
When you are done, remember to close the program!
6If you would like to delete all of the contents of the trash you could use sudo and remove the entire directory. Remember to remake the directory so it doesn't cause any problems. The code is:
sudo rm -rf /home/User_Name/.local/share/Trash && mkdir /home/User_Name/.local/share/TrashThat will do it all with one entry into the terminal.
I personally use trash-cli a lot. I use it as an alternative to rm to be safe (e.g. trash -r my-folder).
sudo apt install trash-cliOnce installed you can do
sudo trash-empty 2 run this in your cmd
sudo rm -rf ~/.local/share/Trash/* 2 Use the terminal!1eleven (drag and drop)
- Open a terminal with Ctrl+Alt+t.
- To take ownership of the files again and continue in your filemanager, type the command
sudo chown -R $USER:$USERand make sure there is a space at the end. Now drag the the affected file or folder from your filemanager to the terminal.
The result should look like this:
sudo chown -R $USER:$USER '/home/$USER/.local/share/Trash/files/some_file.txt'or this:
sudo chown -R $USER:$USER '/media/$USER/path to external drive/.Trash-1000/files/sömё fïle thät may have fancy encodings, ſpaces & stu𝖋f.txt'where
$USERstands for your user name in the path name.
Run the command by pressing Enter and probably refresh the view with F5 in the filemanager.
- As noted by David Foerster, you can replace the apostrophes with quotation marks, to have shell variable expansion.
Using the terminal with files isn't that difficult when drag and drop works, is it? ^^ It is a very handy feature when you know how to use it.
Alternatively you can delete single files with rm. Deleting folders can be done with rmdir for empty folders or rm -r for deleting files and folders recursively. While the drag and drop method should work in almost all cases and properly escape everything you should still be careful when using deletion commands. Owning the files and deleting them in your filemanager is the safer solution.
Related
2TL;DR: install trash-cli and execute:
sudo HOME=/home/<your-home-dir> trash-emptyWhy are the other solutions wrong? They fall into two categories:
- Delete everything in the trash folder
- Run a command that actually does something different than the OP asked
Solutions of type 1 are wrong because the trash folder has structure that should not be modified directly. Whatever manages it keeps a small database there. If you delete that database, you risk breaking the trash functionality altogether. This may not be the case at this time, but may become the case at any point in the future.
The type 2 solution is sudo trash-empty, which empties root's trash instead of "your" trash. Without sudo, it would run into the original issue.