Cannot remove file from trash that was put there as root
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!
If 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/Trash
That 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-cli
Once installed you can do
sudo trash-empty
run this in your cmd
sudo rm -rf ~/.local/share/Trash/*
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:$USER
and 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
$USER
stands 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
- How can I empty the trash using terminal?