2 Replies Latest reply: Dec 3, 2012 7:18 AM by muvvas RSS

    Reg: USERS

    948062
      Hi all,

      I wnt to list out all the users belong to a particular group say amld.



      i use getent groups i didn't find

      can u sggest me how to view all users belong to existing group in unix.
        • 1. Re: Reg: USERS
          Darren Moffat-Oracle
          What nameservice configuration do you have enabled for groups ?

          $ grep ^group /etc/nsswitch.conf

          Note that:

          $ getent group <groupname>

          does work however it only lists users that have been given the group as a supplementary one not their primary group in their passwd entry.

          The groups command lists all groups (primary and supplementary) for a given user.

          If you want to list all the users that have a given group (say 10) as their primrary group you need to look at the passwd database not the group one eg:

          $ getent passwd | nawk -F: '$3 ~ /10/ { print $1}'

          That will print all the users in group 10 (usually called staff).
          • 2. Re: Reg: USERS
            muvvas
            first list groups with groups command
            then use

            logins -g groupname

            bash-3.2# logins -g sys
            root 0 root 0 Super-User
            bin 2 bin 2
            sys 3 sys 3
            adm 4 adm 4 Admin