20

I am a user of Xubuntu and I have a problem with it. When I delete any files outside home they can't be deleted and instead of that, a message appears to me and says "Unable to find or create trash directory". I hope I find a solution for this problem, as I can't get rid of useless files. Thanks.

2
  • It is probably a mounting problem. Please post the line from /etc/fstab where the directory resides.
    – Rinzwind
    Mar 1 '13 at 19:43
  • I have no folder in etc called fstab but I have fstab.d Mar 5 '13 at 19:27
19

No need to have it somewhere else to copy it:

First, confirm that your normal user is ID "1000":

$ id

Then

$ sudo mkdir -p /.Trash-1000/{expunged,files,info}
$ sudo chown -R $USER /.Trash-1000
4
  • This did not work for me. Also, the second command entered a prompt asking for additional information. Aug 16 '14 at 21:42
  • I've edited my answer... try now.
    – Greg Bell
    Aug 18 '14 at 4:55
  • 2
    Xubuntu appears to delete user files to /home/user/.local/share/Trash (containing the three aforementioned sub-folders) these days. Might want to add that information.
    – Adrian
    Dec 16 '16 at 14:04
  • Working for me. Thanks. May 18 '20 at 5:18
13

If you have touched your /etc/fstab then you have to fix it. Your lines there must be something like /dev/sdc1 /media/Data ntfs-3g defaults,uid=1000,locale=en_US.utf8 0 2.

Note about uid=1000

5
  • I have no folder in etc called fstab but I have fstab.d Mar 5 '13 at 19:27
  • fstab is not a folder, it is a file Mar 6 '13 at 1:14
  • 1
    The trick with uid=1000 (my user id on a single user system) works. But does that not mean that if there is another user, she/he will create all files with myself as the owner? There must be some other solution...
    – ubuplex
    Jan 28 '14 at 20:47
  • 4
    I'm having trouble understanding this answer...what does "Your lines there must be something like ..." mean? Should we add the lines? Are the lines supposed to exist and we should edit them? Feb 17 '17 at 15:22
  • @AbhishekDivekar /etc/fstab's contents will always reflect (describe) how your system is composed. The composition is made up from partitions found on the primary-, and possibly other, connected disks. The system will attempt to mount each partition that has a line about it in /etc/fstab upon system startup. If a partition has no entry here, then you will need to mount that manually, when you need it. However, when there is a line there that does not correspond to any existing real partition, you have problems and errors. So don't just add there just anything, out of experiment.
    – Levente
    Apr 5 at 17:52
6

For me this happened after I added the LXQT window manager; I'm unaware if that is related, but I am using a fresh install and that is all I have done so far, so that is why I mentioned it. To fix it, I simply had to change the permissions for the Trash directory:

sudo chown -R $USER ~/.local/share/Trash
1
  • This worked for me, no idea why it happened in the first place. Don't forget to restart after the command.
    – creativiii
    Oct 11 '19 at 21:26
3

This happens if you delete the trash directory. If you are the only user in the system, it is a hidden directory named ".Trash-1000" in each partition (HDD or removable device). This must contain three directories: 1. "expunged" 2. "files" 3. "info"

I would suggest copying the directory from another partition and deleting the files in it.

I had the same problem and it was solved this way. Your case may be different.

2
  • 2
    That explains why it can't "find" the trash directory. Do you have any idea why it wouldn't be able to "create" it? (I am not saying this answer is wrong; I think it is right. I'm just wondering if you have any insight into this.) Mar 23 '13 at 17:46
  • 1
    I really don't know and I have the same question.
    – MakisH
    Mar 23 '13 at 17:50
2

I have a similar problem after installing LXQT/lubuntu and switching back to Ubuntu. A simple solution is to go to ~/.local/share folder and delete the "Trash" folder.

sudo rm -R ~/.local/share/Trash

Then try to delete a file, it will create the default Trash folder with all the required permissions.

0

I solved this by unmounting my NTFS drive and again mounting

0

I solved this issue by remounting by NTFS drive with proper permissions using the flag:

mount -o "uhelper=udisks2,nodev,nosuid,uid=1000,gid=1000,dmask=0077,fmask=0177" <drive name> <mount point>

This assumes your used id is 1000 which you can check with the id command.

0

When automounting using gnome-drives, in the mounting options I wrote:

nosuid,nodev,nofail,x-gvfs-show,uid=1001,gid=1001

In a terminal write id, and whatever is the output should be where I have put 1001 - in your case it might be 1001 or 1000

0

This happens when the file to delete is on a different partition than the trash folder. The trash folder is usually $HOME/.local/share/Trash. The source of the problem is that you can't rename files across partitions.

If this is the root cause, go into the folder which contains the file you want to delete and then:

df -h .

The last column is "Mounted on" which gives you the path on which the partition is mounted. In my case, this is /data

To fix the problem:

cd /data       # <<--- the the value from the df command above
sudo mkdir -p .Trash-$UID/{expunged,files,info}
sudo chown -R $USER .Trash-$UID
sudo chmod -R 0700 .Trash-$UID

This will create a trash can on the partition which is owned by the current user ($USER and $UID).

See also:

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