Find the answer to your Linux question:
Results 1 to 3 of 3
1. [root<at>healmas-pm /]# ls -ld healmas drwxrwsrwx 2 root healmas 4096 Nov 23 19:49 healmas 2. [wrl<at>healmas-pm healmas]$ ls [wrl<at>healmas-pm healmas]$ touch aaa [wrl<at>healmas-pm healmas]$ ls -l total 4 -rw-rw-r-- ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2013
    Posts
    2

    inheritance question of setgid


    1. [root<at>healmas-pm /]# ls -ld healmas
    drwxrwsrwx 2 root healmas 4096 Nov 23 19:49 healmas

    2. [wrl<at>healmas-pm healmas]$ ls
    [wrl<at>healmas-pm healmas]$ touch aaa
    [wrl<at>healmas-pm healmas]$ ls -l
    total 4
    -rw-rw-r-- 1 wrl healmas 0 Nov 23 19:50 aaa
    [wrl<at>healmas-pm healmas]$ groups
    wrl healmas

    3. [wm<at>healmas-pm healmas]$ ls -l
    total 4
    -rw-rw-r-- 1 wrl healmas 0 Nov 23 19:50 aaa
    [wm<at>healmas-pm healmas]$ touch bbb
    [wm<at>healmas-pm healmas]$ ls -l
    total 8
    -rw-rw-r-- 1 wrl healmas 0 Nov 23 19:50 aaa
    -rw-r--r-- 1 wm healmas 0 Nov 23 19:50 bbb
    [wm<at>healmas-pm healmas]$ groups wm
    wm : users healmas

    4. [linp<at>healmas-pm healmas]$ ls -l
    total 8
    -rw-rw-r-- 1 wrl healmas 0 Nov 23 19:50 aaa
    -rw-r--r-- 1 wm healmas 0 Nov 23 19:50 bbb
    [linp<at>healmas-pm healmas]$ touch ccc
    [linp<at>healmas-pm healmas]$ ls -l
    total 12
    -rw-rw-r-- 1 wrl healmas 0 Nov 23 19:50 aaa
    -rw-r--r-- 1 wm healmas 0 Nov 23 19:50 bbb
    -rw-r--r-- 1 linp healmas 0 Nov 23 19:55 ccc
    [linp<at>healmas-pm healmas]$ groups
    users

    5. [liul<at>healmas-pm healmas]$ ls -l
    total 12
    -rw-rw-r-- 1 wrl healmas 0 Nov 23 19:50 aaa
    -rw-r--r-- 1 wm healmas 0 Nov 23 19:50 bbb
    -rw-r--r-- 1 linp healmas 0 Nov 23 19:55 ccc
    [liul<at>healmas-pm healmas]$ touch ddd
    [liul<at>healmas-pm healmas]$ ls -l
    total 16
    -rw-rw-r-- 1 wrl healmas 0 Nov 23 19:50 aaa
    -rw-r--r-- 1 wm healmas 0 Nov 23 19:50 bbb
    -rw-r--r-- 1 linp healmas 0 Nov 23 19:55 ccc
    -rw-rw-r-- 1 liul healmas 0 Nov 23 19:59 ddd
    [liul<at>healmas-pm healmas]$ groups
    liul

    6. [liul<at>healmas-pm healmas]$ cat /etc/group | grep 'healmas\|users\|wrl\|liul'
    users:x:100:wm,linp
    wrl:x:500:
    healmas:x:501:root,wm,wrl
    liul:x:503:


    Question:
    user root created a directory /healmas on redhat es linux5, set its permission to drwxrwsrwx root healmas
    user wrl belongs to groups healmas and wrl, and the created item /healmas/aaa with group write permission
    user wm belongs to groups healmas and users, and the created item /healmas/bbb without group write permission
    user linp belongs to group users, and the created item /healmas/ccc without group write permission
    user liul belongs to group liul, and the created item /healmas/ddd with group write permssion

    why files created by users belong to group users without group write permission while files created by users do not belong to group users with that permission?

  2. #2
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    675
    This is not inheritance, it is just the three tier permissions at work. If you are not the owner userid, then the group membership is attempted, if you are not a member of the group, then the "all others" permissions are used. All the "setgid" on the directory does is make the ownering group the owing group of files and directories within that directory group ownership by that group.

  3. #3
    Just Joined!
    Join Date
    Nov 2013
    Posts
    2
    Quote Originally Posted by alf55 View Post
    This is not inheritance, it is just the three tier permissions at work. If you are not the owner userid, then the group membership is attempted, if you are not a member of the group, then the "all others" permissions are used. All the "setgid" on the directory does is make the ownering group the owing group of files and directories within that directory group ownership by that group.

    thanks, i've got the answer in another place as below, thank you very much.

    Quote Originally Posted by nobody;-999999
    setgid only sets the group ownership (healmas in your example) when a file is created, it does not influence the read, write or execute permissions.

    The actual permissions are influenced by the umask setting. Looking at the above examples it seems to be that the following umasks are in place:

    - wrl -> 0002
    - wm -> 0022
    - linp -> 0022
    - liul -> 0002

  4. $spacer_open
    $spacer_close

Posting Permissions

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