how to list users in linux?…local, remote, real and all users

i have multiple Linux servers in same network i want to list all the users list in all the servers in single shot so any one have idea ..

and each users have different access privileges i want to take all the users details in single shot .


This is done by simply running the who command (without any options). Consider the following example:

$ who
himanshu tty7         2012-08-07 05:33 (:0)
himanshu pts/0        2012-08-07 06:47 (:0.0)
himanshu pts/1        2012-08-07 07:58 (:0.0)

List all local users

You can list all the local users by doing a simple cat of the passwd (/etc/passwd) file.

cat /etc/passwd

List only real users

Let’s assume that the real users on the system have a home directory at /home.

cat /etc/passwd | grep '/home' | cut -d: -f1

List all users

If you need to get a list of all the users that have access to the system across many authentication services such as NIS, LDAP etc, then the command is getent.

You can use the cut, grep and awk commands to modify and format the output as described in the previous commands.

getent passwd | cut -d: -f1

  • I´m going to update the question for a more detailed solution Feb 13 '18 at 13:35
  • For listing real users, I had been thinking of listing all users with a UID greater than the UID_MIN as defined in /etc/login.defs but grepping for home is a good short-cut. Here's how it can be done with a single awk command: awk -F : '/home/ {print $1 }' /etc/passwd Mar 15 '19 at 12:43