Howto: Permissions and ownership on FAT and NTFS filesystems
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Howto: Permissions and ownership on FAT and NTFS filesystems
This seems to be confusing a lot of new users, and although the answers are out there on dozens of threads, I thought it would be worth writing a quick post that pulls everything together in one place.
How can I chmod or chown files on my NTFS/FAT partition?
You can't. chmod and chown will terminate without error if you try it, but you'll find the permissions and ownership haven't changed (Don't worry, you're not the first to be confused by that and you won't be the last).
When you mount a Windows filesystem, Linux sets the permissions for the entire filesystem at mount-time (if you want different files to have different perms/owners... time to change filesystem). FAT doesn't support Unix-style permissions at all, and while NTFS does, the Linux ntfs-3g driver doesn't support that feature. You can control the settings by passing options to the mount command, either at the command line or in /etc/fstab.
The options to use are:
uid: Owner of all files (can be user name or numeric ID)
gid: Group of all files (can be user name or numeric ID)
umask: Octal permissions for all files, in the same way as arguments to chmod, except they're inverted for some obscure reason. So 000 is rwxrwxrwx, 111 is rw-rw-rw-, etc.
dmask: Octal permissions for directories only.
fmask: Octal permissions for regular files (non-directories) only.
Note that any or all options can be omitted, and they'll just take some default value.
Example: mount an ntfs partition with owner openSauce, group users, permissions rwxrwxr-x for directories and rw-rw-r-- for regular files.
Code:
mount -t ntfs -o uid=openSauce,gid=users,dmask=002,fmask=113 /dev/sda6 /mnt/sda6
Remember, no spaces between the mount options!
Example 2: Line in fstab to do the same thing automatically at boot
Please note that if you want to be able to write to NTFS, you'll need the ntfs-3g driver. Most newby-friendly distros should have this installed by default, but if you're using an older or less "automated" one you may have to install it yourself.
Pretty sure I got all that right, but if anyone has corrections or improvements please let me know! Thanks to David the H., theYinYeti, and Mol_Bloom for suggesting improvements.
A long overdue howto. I'll probably be linking to it.
The umask (and fmask/dmask) numbers are not really obscure, they're just the octal number of the permissions that you don't want the files to have. They "mask" the undesired permissions, leaving you with only the ones you do want.
P.S. It would be a good idea to also include a section about enabling write permission, and how you need to be using the nfts-3g driver and not the unfinished kernelspace one.
Last edited by David the H.; 03-09-2009 at 08:51 AM.
Reason: added postscript
Windows filesystems don't support Unix-style permissions
It should be noted that NTFS has support for ACLs. Unfortunately, it is the Linux NTFS driver that misses this feature. Not that it would be easy to setup, though… because Windows users and groups are not quite the same as on your typical Linux install.
Windows filesystems don't support Unix-style permissions
It should be noted that NTFS has support for ACLs. Unfortunately, it is the Linux NTFS driver that misses this feature. Not that it would be easy to setup, though… because Windows users and groups are not quite the same as on your typical Linux install.
The umask (and fmask/dmask) numbers are not really obscure, they're just the octal number of the permissions that you don't want the files to have. They "mask" the undesired permissions, leaving you with only the ones you do want.
I realise that, but it still seems a little quirky to me to do it that way rather than, say, having a uperm option. I'm sure there's a good (historical?) reason for it, but I've no idea what it is. Do you know?
Quote:
Originally Posted by David the H.
P.S. It would be a good idea to also include a section about enabling write permission, and how you need to be using the nfts-3g driver and not the unfinished kernelspace one.
Thanks for your input. I'll edit the post in a day or two when there's been time for more comments to come in.
Quote:
Originally Posted by Mol_Bolom
Looks pretty good OpenSauce...
Out of curiosity, how about adding
Code:
id yourusername
in order to find the values needed for uid and gid...
Thanks, didn't actually know about that command - I've just been looking in /etc/passwd for my numeric ID. However I don't think I'll include it in the howto, since contra my advice to you yesterday, you don't need your numeric ID here - the username works fine.
On my slackware system, id, also, prints out the username as well as the group name. I just mentioned though, because I really didn't know any way of finding the group name before I found id yesterday.
Oh right. Yeah, that is quite useful, although for a single-user machine you don't need to bother about the group too much, you could just omit that option here and leave the group as root. For reference, group information is stored in /etc/group, and Gnome and KDE should both have GUI tools for looking it up as well.
Oh, I keep forgetting about KDE and Gnome...I only use openbox with emelfm2 and mc in terminal.
Quote:
Originally Posted by openSauce
Although for a single-user machine you don't need to bother about the group too much, you could just omit that option here and leave the group as root. For reference, group information is stored in /etc/group, and Gnome and KDE should both have GUI tools for looking it up as well.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.