0

Ubuntu 13.10/W7 dual boot

I have a large folder of photos My Pictures on a separate NTFS partition called Data which I can access from Windows & Ubuntu. I want to make this folder accessible as read-only from my wife's Ubuntu user account. I've tried changing permissions using Nautilus but it doesn't let me. There's no end of eye-glazing advice on folder sharing online but I can't find anything that's applicable, everything seems to assume the folder must be in home directory. Is there a relatively simple way to achieve this?

2 Answers 2

1

1. Add both users to the same group.

To make both users have access to the folder with the same permissions you need to add them to the same user group.

  1. Find out the group of your user.

    The easiest way to achieve this is to add the second user to your own user group. Therefore you have to find out your own group. It usually has the same name as your username. You can find it out in a shell by typing the following when logged in as your user:

    groups
    

    The output should be something like this:

    <somegroupname> adm cdrom sudo dip plugdev lpadmin sambashare
    

    The first entry in place of the <somegroupname> is your primary group, which is the user group by default.

  2. Add the second user to the group.

    To add the second user to your user group you type while logged in as root:

    usermod -a -G <group> <user>
    

    If there was no error, there will be no output.

  3. Find the UID and GID of your user and group.

    You will need to sed owner user and owner group the partition should be mounted with identified by their ID. Find the user ID by typing

    id -u
    

    while logged in as your user. Find the group ID by executing

    id -g
    

    while logged in as your user.


2. Make sure the partition is mounted with the correct umask for your needs.

  1. Determine which umask (Wikipedia has a very detailed explanation, if you are interested) would be appropriate.

    In short the umask is the reverse mask of the usual unix filesystem permissions, which are basically split up into read, write and execute, in short r, w and x. Those are represented on filesystem level by octal values of r=4, w=2 and x=1. If you want to combine permissions you simply add the values, so a value of 6 (which would look like "rw-") would allow a user to read and write to a file, for example.

    There are three groups of these permissions for each file or directory on your system, the first one regarding the owner user of the file, the second one regarding the owner group and the third one regarding everybody else. If you type ls -l, you can see the permissions of each file in the folder by an output like this:

    -rw-r----- 1 david coworkers 241232 Apr 10 21:17 test.txt
    

    The permissions in the above line would be split into the first -, which is the bit referencing the type of the file (i. e. directory or link), rw-, r-- and ---, which would allow the user david to read and write to the file and anyone in the group coworkers to read it, while anybody else would not be allowed to do anything with the file.

    Having that in mind, you will conclude that you primarily want to set the part of the umask regarding the group, because you added your wife to yours and therefore can manage the permissions for both of you by managing the permissions for the group.

    As I said, the umask is the reverse mask of the permissions - which means you take the number 8 and subtract the value of the permissions you wish to apply, respectively for the user, group and others, i.e. 5 for read and execute. These are the default permissions set for the group and others by most linux distributions - files created with this umask end up with 4-permissions, direcories with 5.

    Basically you want to grant your wife and yourself full access to all files so I would recommend to use a umask like 002 or 003.

  2. Find out which partition you need to configure / check.

    There are plenty of commands you can execute to find out which partition or device you will need to check and maybe configure. The output of df, blkid or fdisk -l should help you find the right one. I usually use

    df -h
    

    which should output something like this

    Filesystem      Size  Used Avail Use% Mounted on
    /dev/sda2       8,0G  6,5G  1,2G  85% /
    /dev/sda3       233G  137G   96G  59% /mnt/data
    

    and

    blkid -t TYPE=ntfs
    

    which would result in something like this:

    /dev/sda3: UUID="B474E96674E92BB4" TYPE="ntfs"
    
  3. Edit your /etc/fstab file.

    Open the fstab file with an editor while logged in as root like this

    vim /etc/fstab
    

    and find the line regarding the ntfs partition, identified by the UUID, the device name (i.e. /dev/sda3) and/or the mount point (i.e. /mnt/data). Change it to something like the following (using the information you gathered previously):

    # <file system>         <mount point>   <type>  <options>                        <dump>  <pass>
    /dev/sda3               /mnt/data       ntfs    uid=1000,gid=1000,umask=0003     0       0
    

    OR

    # <file system>         <mount point>   <type>  <options>                        <dump>  <pass>
    UUID="B474E96674E92BB4" /mnt/data       ntfs    uid=1000,gid=1000,umask=0003     0       0       
    

    either defining the partition by it's device name or it's UUID.

    Be carefull to not delete options that are already set, though of course there should not be any duplicates in the options section of this partition.

  4. Reboot your PC.


If I recall correctly, this will be the only option because the unix permissions are not saved to the NTFS structure permanently but the system only remembers them for the time it is mounted. So setting owners, groups and permissions with chown, chgrp and chmod will probably not help on the long run but only for the time until the device will be unmounted once again - which at the latest will be the next time you shutdown your PC.


[EDIT FOR COMPLETENESS]

As my first comment suggests, there might be a method to save unix permissions to an ntfs file system, but I cannot verify this for I have not tried it myself. I personally use the way I described above.

5
  • I just found this -> unix.stackexchange.com/a/11759. Seems you might be able to maintain the unix permissions on an NTFS partition, though I'm not really sure about that.
    – David
    Mar 25, 2014 at 20:03
  • Answer 1 doesn't have "Add comment" option but what I need is an idiot-proof step-by-step procedure which I take be something like:
    – user261979
    Mar 26, 2014 at 14:47
  • Add wife's user name to my group, then usermod -a -G group user (not sure if this is necessary), logout login, add this to /etc/fstab: /dev/sda7 /mnt/Data ntfs uid=1000,gid=1000,umask=0003 0 0 (Data with upper case D is on sda7). A couple of supplementaries, wife does't have password at moment, presumably will need one; The actual file My Pictures doesn't appear anywhere in the above, does this mount the entire Data partition in her login?
    – user261979
    Mar 26, 2014 at 15:02
  • I'll update my answer later to fit your needs.
    – David
    Mar 26, 2014 at 21:06
  • Sorry I let you wait for so long. Time played against me.
    – David
    Apr 10, 2014 at 19:58
0

You can change perrmitions like this

sudo chmod -R 754 /mypictures


chmod command sets the permission of a file or folder.

chmod command uses three digit code as an argument and the file or folder location.

In the example,

7 – Owner(current user)

5 – Group(set by owner)

4 – anyone else


The fundamental concept:

Execute is 1, Write is 2 and Read is 4.


Sum of these basic ones makes combination of permissions:

0 – no permission, this person cannot read, write or execute

1 – execute only

2 – write only

3 – execute and write only (1 + 2)

4 – read only

5 – execute and read only (1 + 4)

6 – write and read only (2 + 4)

7 – execute, write and read (1 + 2 + 4)

2
  • 1
    I don't think this will work permanently with an NTFS partition.
    – David
    Mar 25, 2014 at 19:40
  • No i don't think so either, i need to read the questions another couple of times or more to understand. I actuary thought The share was setup already and wanted to change the permissions to the Pics so the 2nd Ubuntu will only have read only permissions. I skipped the "Ubuntu 13.10/W7 dual boot" part. :))
    – Tasos
    Mar 25, 2014 at 19:56

You must log in to answer this question.

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