Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to delete files in Nautilus and every time I try to delete one it always gives me this message:

Cannot move file to trash, do you want to delete immediately?

Then it gives me several questions. All I want is that when I press Delete in the keyboard it sends it automatically to the trash can. Not to ask me every time.

The problem relates to NTFS partitions, external drives but also include Linux filesystems.

What are the reasons for nautilus beeing not able to move to trash?

enter image description here

share|improve this question
    
can you provide the full(absolute)path of the file –  aneeshep Nov 3 '11 at 16:32
    
In this case is /var/www. Am already the owner of it and permissions are good. But there is also external units like hard drives and pen drive that have the same issue. –  Luis Alvarado Nov 3 '11 at 17:21

4 Answers 4

up vote 8 down vote accepted
+50

(About removable media, not the case from the user since it was a bug solved with an update)

This behaviour happens because when the drive is mounted you are not considered the owner so a trash bin cannot be created. No uid or gid was assigned and since a trash bin folder cannot be created in the drive you are only offered the choice to delete the files automatically.

In that case you have 2 options: cut the files in to your Linux file system and delete them there (which defeats the purpose of press delete and the files are deleted) or make sure you are assigned the correct permissions when mounting the drive.

Create a new rule for your auto-mounted drives with these lines, use your favorite text editor for that

gksudo gedit /etc/udev/rules.d/10-my-media-automount.rules

# vim:enc=utf-8:nu:ai:si:et:ts=4:sw=4:ft=udevrules:
#
# /etc/udev/rules.d/10-my-media-automount.rules

# start at sdb to ignore the system hard drive
KERNEL!="sd[b-z]*", GOTO="my_media_automount_end"
ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="my_media_automount_end"

# import some useful filesystem info as variables
IMPORT{program}="/sbin/blkid -o udev -p %N"

# get the label if present, otherwise assign one based on device/partition
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"

# create the dir in /media and symlink it to /mnt
ACTION=="add", RUN+="/bin/mkdir -p '/media/%E{dir_name}'"

# global mount options
ACTION=="add", ENV{mount_options}="relatime"
# filesystem-specific mount options (777/666 dir/file perms for ntfs/vfat) 
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},gid=46,dmask=000,fmask=111,utf8"

# automount ntfs filesystems using ntfs-3g driver
ACTION=="add", ENV{ID_FS_TYPE}=="ntfs", RUN+="/bin/mount -t ntfs-3g -o %E{mount_options} /dev/%k '/media/%E{dir_name}'"
# automount all other filesystems
ACTION=="add", ENV{ID_FS_TYPE}!="ntfs", RUN+="/bin/mount -t auto -o %E{mount_options} /dev/%k '/media/%E{dir_name}'"

# clean up after device removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l '/media/%E{dir_name}'", RUN+="/bin/rmdir '/media/%E{dir_name}'"

# exit
LABEL="my_media_automount_end"

Reboot your computer and your ntfs drives will be mounted using this custom rule, to change the permissions for the mounted drive have a look at the line $env{mount_options},gid=46,dmask=000,fmask=111,utf8", the option gid=46 should mount the ntfs drive with group privileges (46(plugdev) is the group that allows a user to mount a drive in Ubuntu), fmask and dmask settings to write, create, delete files/folders on the drive.

Change it according to needs. You will need to sort out other file systems by yourself according to to each type but this should get your started.

(Source for the udev rule)

share|improve this answer
    
Does this also works for me? I have a slight different environment: Using Linux only, and I have NFS mounted home where deleting is working quite well and there also exists a trash, but I have symlinked a directory repos to local filesystem /local/home/me/repos (its faster). Only inside this directory and subdirectories deleting does not work. Directories /local/home are owned by root 755, but my directories /local/home/me/repos are owned by me with modalities 700. –  math Jan 9 '12 at 9:57

Maybe you can find the answer here:

http://www.computerandyou.net/2011/06/how-to-solve-cannot-move-file-to-trash-do-you-want-to-delete-immediately/

share|improve this answer
1  
That did not solve the problem. It was in the end an issue that after updating it was fixed. I will change the question since this also addresses another problem that is fixed by your link. Before accepting the answer please put the answer here in askubuntu instead of linking to another site. After that I will accept the answer. –  Luis Alvarado Nov 25 '11 at 18:46

I used to have this problem when I added a line in /etc/fstab for mounting a ntfs partition. It was not present if I mounted the partition "manually" in nautilus.

The Ubuntu documentation explains that you should mount disks using udisks, which is what nautilus uses.

Summary of the steps for automatically mounting a partition:

  1. Prerequisite: mount the partition and find its name (for example /dev/sdb1) using the mount command.

  2. Get the uuid of the partition. The uuid appears before the -> in this command:

    ls -al /dev/disk/by-uuid/

  3. The command for mounting will be:

    /usr/bin/udisks --mount /dev/disk/by-uuid/<the uuid you found previously>

  4. Add this command in your startup applications

share|improve this answer
1  
This is not let you execute files in the ntfs partition –  Anwar Shah May 20 '12 at 10:38

For cases where the user can not delete a file stored in a non-removable partition (Ubuntu 14.04)

As Bruno Pereira stated, this behaviour happens because the user does not have write permissions at the mount point of the partition (in the OP case, /var), so a directory for the trash bin can not be created.

In this case, the OP can not move to trash files stored at the /var partition. To solve this issue:

$ cd /var
$ sudo mkdir .Trash-1000
$ chown user:group .Trash-1000

You will have to replace:

  • 1000 by your user identifier (see the number following your login name at the file /etc/passwd)
  • user:group by your login name and group, respectively
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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