This is done by simply running the
who command (without any options). Consider the following example:
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.
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
You can use the
awk commands to modify and format the output as described in the previous commands.
getent passwd | cut -d: -f1