Permission problem on /media/user folder prevents me from accessing external media

Since the permissions & ownership of /media/casper are

drwxr-x---  root root 

With no + for ACLs (Access Control Lists) it's clear that only root can open, enter, read or write to this directory. Humble users like us get the permissions at the end of the string --- :(

We unprivileged folk get permission to access this location with ACLs. I am not sure why you don't have these already, but you can set them up, which may be simple or require a little tinkering:

  • the acl package is required (check apt-cache policy acl)
  • the filesystem must be mounted with the acl option

To check the latter (replace sdxY appropriately for your root partition):

sudo tune2fs -l /dev/sdxY | grep "Default mount options:"

should return:

Default mount options:    user_xattr acl

Default mount options are set in /etc/mke2fs.conf

They may be overridden, so check:

cat /proc/mounts | grep sdxY

looks something like:

/dev/sdxY / ext4 rw,relatime,errors=remount-ro,data=ordered 0 0

The above is fine, (acl doesn't need to be mentioned) but if it says noacl you need to change it.

You can add the option to default mount options like this:

sudo tune2fs -o acl /dev/sdxY

Or you can add acl to the options for the root partition line in /etc/fstab for example:

UUID=whatever /     ext4    errors=remount-ro,acl    0       1

With ACLs enabled, use setfacl to add permissions for yourself. To give username read and execute permissions on /media/casper (you need execute permission to enter a directory or search its contents):

sudo setfacl -m u:username:rx /media/casper

You can replace username with uid (probably you are 1000 - check with id command)

sudo setfacl -m u:1000:rx /media/casper

to see the ACL permissions you use getfacl like Oli did in his answer

getfacl /media/casper

To remove ACL permissions from a user

sudo setfacl -x u:username /media/casper

To clear all ACL permissions

sudo setfacl -b /media/casper

Note: I cheated and asked a question myself about why there are so many entries in /media. The answer is here


When you want to give access permission to a Windows drive from Ubuntu

The normal chmod command won't work if it is a Windows NTFS drive.

The following works for me.

Open the file /etc/mtab:

gedit /etc/mtab

Find the drive name in this file (just mouse over on drive for which you are looking for solution, in my case the GUI is showing different name and on mouse over it shows /media/user-name/drive-name)

Now in /etc/mtab:

Search the drive-name in file, and check to which drive your mounted drive is assigned (in my case - /dev/sda4)

Now mount this drive with:

sudo ntfs-3g /dev/sda4 /media/"$USER"

Now I am able to execute my executables, but I won't be able to see contents of drive-name, so I unmounted the drive and mounted it again.