6 Replies Latest reply on Oct 8, 2013 10:22 AM by Bill Robinson

    List users on Linux Server

      How can I use balde logic to get a list of all users on 100 linux servers?

        • 1. Re: List users on Linux Server
          Ashitosh Wagh

          Hi aughsydney,

           

          you can create simple nsh script with content

           

          /bin/awk -F':' '{ print $1}' /etc/passwd

           

          and create NSH script Job and execute on  number of servers you want to check.

           

          Depending on requirement you can get job log or redirect above output in file so you will get all users list.

           

           

          Thanks

          Ashitosh

          • 2. Re: List users on Linux Server
            Niranjan Nagandla

            Or if you have BDSSA reporting in your environment, you can take snapshot on the UNIX users CO followed by an ETL to transfer the data to reporting warehouse and generate a report.

            • 3. Re: List users on Linux Server
              Dipak Gaigole

              You can also use a simple blquery command to do it. Here is a simple example for 2 servers (rhel05-dv08 and sol10-dv04):

               

              bl-appsvr# blquery rhel05-dv08 sol10-dv04 -e 'user_record_count ( "printf (\"%s: %s\n\", $HOSTNAME, NAME);")'

              rhel05-dv08: root

              rhel05-dv08: rdsroot

              rhel05-dv08: bin

              rhel05-dv08: daemon

              rhel05-dv08: adm

              .

              .

              sol10-dv04: root

              sol10-dv04: daemon

              sol10-dv04: bin

              sol10-dv04: sys

              sol10-dv04: adm

              sol10-dv04: lp

              .

              .

              .

              rhel05-dv08: 0

              sol10-dv04: 0

              bl-appsvr#

               

               

              If you have 100 servers, you can also add them in a simple text file and it can be used as server list. Here is a simple example for the same 2 servers.

               

               

              bl-appsvr# echo "rhel05-dv08\nsol10-dv04" > /tmp/hostlistfile

              bl-appsvr# blquery -f /tmp/hostlistfile -e 'user_record_count ( "printf (\"%s: %s\n\", $HOSTNAME, NAME);")'

              rhel05-dv08: root

              rhel05-dv08: rdsroot

              rhel05-dv08: bin

              rhel05-dv08: daemon

              rhel05-dv08: adm

              .

              .

              sol10-dv04: root

              sol10-dv04: daemon

              sol10-dv04: bin

              sol10-dv04: sys

              sol10-dv04: adm

              sol10-dv04: lp

              .

              .

              .

              rhel05-dv08: 0

              sol10-dv04: 0

              bl-appsvr#

               

              If you also need additional details for these users like group, uid, gid, HOME directory, login shell, etc then those can also be listed. Please look at "man blquery" (from nsh prompt) and look for "LOCAL USER AND GROUP ACCOUNTS" section for further details.

               

              Hope this helps.

              -Dipak

              • 4. Re: List users on Linux Server
                Soundappan Shanmugam

                Fantastic DEEPAK..

                • 5. Re: List users on Linux Server


                  Hi All,

                   

                  Apologies for the delay in replying.

                   

                  Many thanks for taking time out to reply.  I do not (and still do not) have a clue as to how to open the command line to run blquery.

                   

                  In the end I came up with this and ran it using the BMC automation console

                   

                  for name in `nexec -e getent passwd|cut -d: -f1|sort`; do

                    groups=`nexec -e id -Gn -- $name`

                    status1=$?

                    if test $status1 = 0; then

                      for group in $groups; do

                        echo `hostname`,$name,$group >> //server.wxyz.com/tmp/users.log

                      done

                    else

                      fail=$status1

                    fi

                  done

                   

                  works a treat.

                   

                  Thanks again for taking time out to assist.

                  p.s. Isn't the BMC Automation console terrible?  It took me days to work out how to run a script.  It is terrible.  Can they not simplify it? (Depot/SCRIPT/JOB!!!! crazy)

                  • 6. Re: List users on Linux Server
                    Bill Robinson

                    what specifically is the problem w/ the gui here?

                     

                    also - why not a snapshot job of the 'unix users' object and then export the results ?  what are you trying to do w/ this list ?