Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I have ext3 partition mounted on /mnt/shared/ as follows Code: $ cat /etc/fstab .. /dev/sda12 /mnt/shared ext3 noauto,users,noatime 0 2 .. $ ls -l /mnt/ .. drwxrwsr-x 3 root ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    jkv
    jkv is offline
    Just Joined!
    Join Date
    Feb 2009
    Posts
    2

    How to change umask for files created in ext2/ext3


    Hi,

    I have ext3 partition mounted on /mnt/shared/ as follows

    Code:
    $ cat /etc/fstab 
    ..
    /dev/sda12 /mnt/shared ext3 noauto,users,noatime 0 2
    ..
    
    $ ls -l /mnt/
    ..
    drwxrwsr-x 3 root users <..> shared
    ..
    Permissions above are of the actual mounted fs.

    Goal is to have all files created on the fs
    1) to belong to group 'users' and
    2) to have this groups permissions set to rw (rwx for directories)
    so that all users who belong to group 'users' have full read/write access to data and
    everyone else to have only read access.

    Now because of setgid bit (s) in group permissions every file created has group 'users' and additionally setgid bit is set for directories. Because every users umask by default (on my system) is set to 0022 all created files will have permissions 644 for ordinary files and 755 for directories.

    Net result of above means that users A and B who both belong to group 'users' won't be able to modify files created by the other.

    So how can I make files created on the fs to be created always with umask 0002 WITHOUT changing default umask for users that is used elsewhere (like in their home directory) ?

    Any ideas ?

  2. #2
    Just Joined! chris81's Avatar
    Join Date
    Jan 2009
    Posts
    62
    Hi

    Quote Originally Posted by jkv View Post
    Hi,
    Permissions above are of the actual mounted fs.

    Goal is to have all files created on the fs
    1) to belong to group 'users' and
    2) to have this groups permissions set to rw (rwx for directories)
    so that all users who belong to group 'users' have full read/write access to data and everyone else to have only read access.
    First, browse up to the root of your hierarchy (/usr, for example)
    then change recursively the group ownership of / by typing :

    sudo chgrp -R 'users' /usr

    Now, all the files and directories that are located in the /usr belongs to group 'users'. Now let's put the rights to that group by typing :

    sudo chmod -R u=g,g=rwx,o=a,a=r /usr

    Now, all members of the group 'users' can read write and execute file from /. Users that are not in the group 'users' can only read. If so, then newly created file will belongs to the user from the group 'users' and won't be editable by other groups, but they will be able to read those files.

    I think it's what you wanted.
    chris81

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •