LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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

Reply
 
Search this Thread
Old 03-09-2009, 07:00 AM   #1
openSauce
Member
 
Registered: Oct 2007
Distribution: Fedora, openSUSE
Posts: 252

Rep: Reputation: 39
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
Code:
/dev/sda6    /mnt/sda6    ntfs    uid=openSauce,gid=users,dmask=002,fmask=113    0 0
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.

Last edited by openSauce; 03-10-2009 at 09:52 AM.
 
Old 03-09-2009, 08:40 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
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
 
Old 03-09-2009, 09:03 AM   #3
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 61
Quote:
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.

Yves.
 
Old 03-09-2009, 09:03 AM   #4
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 61
Quote:
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.

Yves.
 
Old 03-09-2009, 11:05 AM   #5
Mol_Bolom
Member
 
Registered: Nov 2008
Location: S.W. Kansas
Distribution: Slackware64 14.0
Posts: 219
Blog Entries: 2

Rep: Reputation: 41
Looks pretty good OpenSauce...

Out of curiosity, how about adding
Code:
id yourusername
in order to find the values needed for uid and gid...
 
Old 03-09-2009, 11:25 AM   #6
openSauce
Member
 
Registered: Oct 2007
Distribution: Fedora, openSUSE
Posts: 252

Original Poster
Rep: Reputation: 39
Quote:
Originally Posted by David the H. View Post
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. View Post
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 View Post
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.
 
Old 03-09-2009, 11:39 AM   #7
Mol_Bolom
Member
 
Registered: Nov 2008
Location: S.W. Kansas
Distribution: Slackware64 14.0
Posts: 219
Blog Entries: 2

Rep: Reputation: 41
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.
 
Old 03-09-2009, 11:44 AM   #8
openSauce
Member
 
Registered: Oct 2007
Distribution: Fedora, openSUSE
Posts: 252

Original Poster
Rep: Reputation: 39
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.
 
Old 03-09-2009, 11:52 AM   #9
Mol_Bolom
Member
 
Registered: Nov 2008
Location: S.W. Kansas
Distribution: Slackware64 14.0
Posts: 219
Blog Entries: 2

Rep: Reputation: 41
Oh, I keep forgetting about KDE and Gnome...I only use openbox with emelfm2 and mc in terminal.

Quote:
Originally Posted by openSauce View Post
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.
Perhaps add that bit of info.
 
  


Reply

Tags
chmod, chown, fat, filesystem, ntfs, owner, permission


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I messed up permissions and ownership digity Linux - Newbie 8 12-07-2008 06:02 PM
permissions and ownership on dir gabsik Linux - Software 4 02-05-2007 06:48 AM
files called 'aux.*' on FAT filesystems? suselapper Linux - Software 10 11-11-2005 11:47 AM
Howto: set permissions on a ntfs drive. Coramoor Slackware 8 05-12-2003 10:51 PM
Access attributes & ownership on FAT filesystem correro Linux - General 2 03-18-2003 08:04 PM


All times are GMT -5. The time now is 07:53 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration