Ubuntu: Questions and Answers (2014)
Permissions
Questions
Q: How do I use 'chmod' on an NTFS (or FAT32) partition?
Tags: permissions
I have a script that I need to execute on an NTFS partition. The script's permission is set to 600.
I attempted to modify the permissions by running chmod 755 script.sh, which doesn't report a failure or anything - but it also doesn't change the permissions on the file:
Skip code block
$ stat script.sh
File: `script.sh'
Size: 297070 Blocks: 584 IO Block: 4096 regular file
Device: 811h/2065d Inode: 35515 Links: 1
Access: (0600/-rw-------) Uid: ( 1000/ xxxxxx) Gid: ( 1000/ xxxxxx)
Access: 2010-09-30 14:05:16.041621000 -0700
Modify: 2010-09-30 14:05:05.070157000 -0700
Change: 2010-09-30 14:05:05.070475000 -0700
$ chmod 755 script.sh
$ stat script.sh
File: `script.sh'
Size: 297070 Blocks: 584 IO Block: 4096 regular file
Device: 811h/2065d Inode: 35515 Links: 1
Access: (0600/-rw-------) Uid: ( 1000/ xxxxxx) Gid: ( 1000/ xxxxxx)
Access: 2010-09-30 14:05:16.041621000 -0700
Modify: 2010-09-30 14:05:05.070157000 -0700
Change: 2010-09-30 14:05:05.070475000 -0700
As you can see, it remains unchanged.
Tags: permissions
User: nathan-osman
Answer by htorque
The mode is determined by the partition's mount options (you cannot change it via chmod).
For '755' on files and '777' on directories you would use something like
sudo mount -t ntfs -o rw,auto,user,fmask=0022,dmask=0000 /dev/whatever /mnt/whatever
Answer by janc
Contrary to what most people believe, NTFS is a POSIX-compatible filesystem, and it is possible to use permissions on NTFS.
To enable this, you need a "User Mapping File" or just give the permissions option when mounting (when no compatibility with Windows is needed). This maps linux users on your system with the user IDs like NTFS/Windows use them internally.
See the ntfs-3g manpage for some info and some examples. If you need more information, see the ntfs-3g advanced documentation about ownership and permissions.
(Note that this does not work on FAT filesystems.)
Yes, it can also store filenames that are valid in linux/unix but not under Windows, supports symlinks & hardlinks, etc.
Answer by dbrews
In addition to setting the fmask and/or dmask in htorque's answer above, if you want to execute scripts on the drive, I had to also set the "exec" mount option.
So the example would be:
sudo mount -t ntfs -o rw,auto,user,fmask=0022,dmask=0000,exec /dev/whatever /mnt/whatever
Tags: permissions
Q: Change folder permissions and ownership
Q: How do I use 'chmod' on an NTFS (or FAT32) partition?
Q: How do I change my username?
Q: How can I get octal file permissions from command line?