1

Could someone kindly explain why I get this Permission Denied error? I personally am user g and as ls shows I have read and write permission for both source and destination. My system is slackware 14, and the device being written to is my ereader, an ntfs-3g file system.

I have other ntfs file systems, thumb drives, external HDDs etc to which I can write to as user. There is no perceptible difference in the permissions setup for any of them. Being ntfs, all of them are owned by root of group root. It is only with this ereader that I have this problem (though I can write to it as root). So I believe the problem is specific to this device, but I have no clue what it might be.

~ $ cp /home/g/MyBooks/Wyndham-TheMidwichCuckoos.txt /500gb/database/media/  
cp: cannot create regular file '/500gb/database/media/Wyndham-TheMidwichCuckoos.txt': Permission denied  
~ $ ls -l /home/g/MyBooks/Wyndham-TheMidwichCuckoos.txt                         
-rw-r--r-- 1 g users 380183 Aug 10 11:04 /home/g/MyBooks/Wyndham-TheMidwichCuckoos.txt  
~ $ ls -l /500gb/database/  
total 32  
drwxr-xr-x 2 root root 8192 Aug 10 11:23 cache/  
drwxr-xr-x 3 root root 8192 Aug  5 13:26 layout/  
drwxr-xr-x 2 root root 8192 Aug  9 14:07 media/  
drwxr-xr-x 2 root root 8192 Aug  5 17:28 sync/  
~ $

The ereader is fat32, I had assumed it to be ntfs,
~ $ mount
/dev/sda3 on / type ext2 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
/dev/sda4 on /home type ext2 (rw)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /winxp type fuseblk (rw,allow_other,blksize=4096,default_permissions)
/dev/sdb on /500gb type vfat (rw)
/dev/sdd1 on /3tb type fuseblk (rw,allow_other,blksize=4096)
~ $ cp /home/g/MyBooks/Wyndham-TheMidwichCuckoos.txt /3tb
~ $ cp /home/g/MyBooks/Wyndham-TheMidwichCuckoos.txt /500gb
cp: cannot create regular file '/500gb/Wyndham-TheMidwichCuckoos.txt': Permission denied
~ $

I am not able to change the permissions on this ereader, neither as root, nor as user
As root, it appears to work, but nothing changes
/home/g # chmod 777 -R /500gb/database
/home/g # ls -l /500gb/database
total 32
drwxr-xr-x 2 root root 8192 Aug 10 11:23 cache
drwxr-xr-x 3 root root 8192 Aug 5 13:26 layout
drwxr-xr-x 2 root root 8192 Aug 9 14:07 media
drwxr-xr-x 2 root root 8192 Aug 5 17:28 sync

As user, the chmod is rejected thus
~ $ chmod 777 -R /500gb/database
chmod: changing permissions of '/500gb/database': Operation not permitted
chmod: changing permissions of '/500gb/database/cache': Operation not permitted
chmod: changing permissions of '/500gb/database/cache/cacheExt.xml': Operation not permitted
chmod: changing permissions of '/500gb/database/cache/media.xml': Operation not permitted
chmod: changing permissions of '/500gb/database/cache/cacheExtSchema_1.1.xsb': Operation not permitted
chmod: changing permissions of '/500gb/database/media': Operation not permitted
chmod: changing permissions of '/500gb/database/media/Stevenson-TreasureIsland.txt': Operation not permitted
chmod: changing permissions of '/500gb/database/media/Rendell-WolftotheSlaughter.txt': Operation not permitted

This process did the trick for me, thanks to Miroslav Koskar
/home/g # mount | grep sdb
/home/g # mount /dev/sdb -o uid=1000,gid=100 /500gb
/home/g # mount | grep sdb
/dev/sdb on /500gb type vfat (rw,uid=1000,gid=100)
/home/g # ls -l /500gb/database
total 32
drwxr-xr-x 2 g users 8192 Aug 10 11:23 cache
drwxr-xr-x 3 g users 8192 Aug 5 13:26 layout
drwxr-xr-x 2 g users 8192 Aug 10 12:51 media
drwxr-xr-x 2 g users 8192 Aug 5 17:28 sync
/home/g #
~ $ cp /home/g/MyBooks/Wyndham-TheMidwichCuckoos.txt /500gb/database/media
~ $

4
  • Did you see this? It probably has something to do with your problem
    – VL-80
    Aug 10, 2013 at 18:50
  • Sorry I should have given the additional info (para 2) that I have just added to the original post. I can write to it as root, and its permissions, ownership etc are identical to other ntfs devices to which I can write as user
    – user985675
    Aug 10, 2013 at 19:24
  • Mount the ereader and one of your “other NTFS file systems”, type mount, and post the output from that. Also, please verify that, on the other devices, you (as a non-root user) can create new files in directories that are owned by root and are mode 755 (rwxr-xr-x). Aug 10, 2013 at 19:39
  • Added to end of original post
    – user985675
    Aug 10, 2013 at 20:04

2 Answers 2

1

It seems to me that permissions are not correctly set.

  1. you are user g and can read a file = OK

  2. but you can't create a file in a destination because the directory media is not writeable by you, only root can do that

So either copy as root or change the permissions on target so that you have a write permission on media directory.


As pointed out it's not possible to change permissions nor ownership on mounted NTFS filesystem. In that case there is a possibility to use proper mount options. Bellow excerpt from man mount

uid=value, gid=value and umask=value

Set the file permission on the filesystem. The umask value is given in octal. By default, the files are owned by root and not readable by somebody else.


Example: (for /dev/sdc1 with FAT32 filesystem)

Check that the device is not mounted (following should return without output)

$ mount | grep sdc1

Mount the device with uid and gid option set

$ sudo mount /dev/sdc1 -o uid=1000,gid=1000 /mnt

Verify the mountpoint

$ mount | grep sdc1

/dev/sdc1 on /mnt type vfat (rw,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
7
  • You cannot change the ownership or group of ntfs file systems, they are always root:root. As far as I am aware, the first triad of permissions shown by ls -l refers to the current user (in this case myself, g), the second triad to all other users in the same group, and the third triad is to all other groups, so I have write permission to this device.
    – user985675
    Aug 10, 2013 at 19:33
  • 1
    Well, the first triad is not for current user but for owner. So you don't have a correct permissions and that's the problem. For NTFS, right it might be a problem that you can't change the permission while mounted. In that case I think you can specify ownership by some mount option. Aug 10, 2013 at 19:50
  • My apologies, you are correct. Not only that, the ereader is fat32 rather than ntfs as I had assumed, and the problem seems to be that I cannot change its permissions at all, neither as root nor as user. See additional info added at end of original post
    – user985675
    Aug 10, 2013 at 20:26
  • Maybe you should set mount options as pointed out in my answer, they are the same for NTFS and FAT like filesystems. Aug 10, 2013 at 20:36
  • Like this? /home/g # mount -t vfat -O uid=1000,gid=100,umask=0755 /dev/sdb /500gb /home/g # ls -l /500gb/database total 32 drwxr-xr-x 2 root root 8192 Aug 10 11:23 cache drwxr-xr-x 3 root root 8192 Aug 5 13:26 layout drwxr-xr-x 2 root root 8192 Aug 10 12:51 media drwxr-xr-x 2 root root 8192 Aug 5 17:28 sync /home/g # chmod -R 777 /500gb/database /home/g # ls -l /500gb/database total 32 drwxr-xr-x 2 root root 8192 Aug 10 11:23 cache drwxr-xr-x 3 root root 8192 Aug 5 13:26 layout drwxr-xr-x 2 root root 8192 Aug 10 12:51 media Its the same as before
    – user985675
    Aug 10, 2013 at 20:53
0

The media directory is owned by root (with a group of root) and is mode 755, so it is writable only by its owner (root).  You’re trying to create a file in that directory (you’re not overwriting an existing file, are you?) which is treated as a modification of the directory.  And you’re not running as root.  That’s probably why you don’t have permission.

Either chown the media directory to yourself (or chmod it so you can write to it), or run the cp under su or sudo.

1
  • Here is the result of chown on /500gb. As you see it makes no difference to the existing setup /home/g # chmod 777 -R /500gb /home/g # ls -l /500gb/database/ total 32 drwxr-xr-x 2 root root 8192 Aug 10 11:23 cache drwxr-xr-x 3 root root 8192 Aug 5 13:26 layout drwxr-xr-x 2 root root 8192 Aug 9 14:07 media drwxr-xr-x 2 root root 8192 Aug 5 17:28 sync /home/g # ls -l /500gb total 8 drwxr-xr-x 6 root root 8192 Aug 5 17:28 database /home/g #
    – user985675
    Aug 10, 2013 at 19:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .