Linux Mint – Unable to Send Items to Trash

Some time ago I noticed that whenever I attempted to move a file (or group of files) to the Trash (or the Rubbish Bin as we in the southern hemisphere – and by extension Mint – like to call it) I received the following error:

“Cannot move file to the rubbish bin, do you want to delete immediately? The file foo.bar cannot be moved to rubbish bin.”

While in many situations permanently deleting a file isn’t such a big deal I do, however,  sometimes find that I’ve accidentally deleted the wrong file or a file that I’ve not quite finished working with. In these situations it can be handy to retrieve the file from the Trash.

Also, when using a graphical file manager I’ve got into the habit of sending most of what I delete to the Trash for a while before I later delete them permanently. And, to tell you the truth, constantly dealing with error messages was just plain painful.

As the error message sounded to me like the problem was something to do with ownership or permissions I had a bit of a poke around in ~/.local and found that, the solution to this little problem was as simple as fixing a partitions problem in my home folder.

Problem: When attempting to delete files using Nautilus the following error “Cannot move file to the trash, do you want to delete immediately? The file foo.bar cannot be moved to trash” is displayed.

Solution: Ensure user has correct ownership and permissions of directories and subdirectories required for Trash to operate correctly.

Procedure: Open a terminal to check ownership and permissions of trash directories.

ls -al ~/.local/share/Trash/

You should see an output something like this:

d---------  2 pseudomorph pseudomorph  4096 2012-03-07 15:07 expunged
d---------  5 pseudomorph pseudomorph 16384 2012-03-12 22:03 files
d---------  2 root        root        20480 2012-03-12 22:03 info

Here you can see that not only does my user (pseudomorph) not have permissions to read/write to the expunged, files or info directories, it also doesn’t have ownership of the info directory.

First, let’s give ownership of the info directory to user pseudomorph. This command will change both the ownership and group of the Trash directory and all its subdirectories to that of the current user.

sudo chown -R $USER:$USER ~/.local/share/Trash/

The output of your ls on the Trash directory should now show something like this:

d---------  2 pseudomorph pseudomorph  4096 2012-03-07 15:07 expunged
d---------  5 pseudomorph pseudomorph 16384 2012-03-12 22:03 files
d---------  2 pseudomorph pseudomorph 20480 2012-03-12 22:03 info

Now lets fix the permissions error with a similar command.

chmod -R 770 ~/.local/share/Trash/

This command will give read/write/execute permissions to both root and the owner of the directories while giving no permissions to others.

The result of your ls command should now show something like this:

drwxrwx---  2 pseudomorph pseudomorph  4096 2012-03-07 15:07 expunged
drwxrwx---  5 pseudomorph pseudomorph 16384 2012-03-12 22:03 files
drwxrwx---  2 pseudomorph pseudomorph 20480 2012-03-12 22:03 info

Your Trash, Rubbish Bin or whatever you call it where ever you live should now work just fine.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s