How to check list of users in Unix

I am a new Unix system user. How can I view system users in Unix operating system using the command line option?

The password file /etc/passwd contains one line for each user account. The passwd files are the local source of password information. Some system stores encrypted passwords in a separate file for security reasons. For example, on a FreeBSD you have /etc/master.passwd or on a Linux you have /etc/shadow file. The /etc/group file is the local source of group information/membership. This tutorial explains how to check the list of users in Unix operating system such as macOS, FreeBSD, OpenBSD, NetBSD, Unix-like system.

Command to check list of users in Unix

On a FreeBSD/OpenBSD/NetBSD and many other Unix-like system, just type the following cat command/more command/less command to get a list of all user accounts:
$ cat /etc/passwd
$ more /etc/passwd
$ less /etc/passwd

Sample outputs:
How to check list of users in Unix

Understanding file format

Consider the last line:

vnstat:*:284:284:vnStat Network Monitor:/nonexistent:/usr/sbin/nologin


  1. vnstat – User name
  2. * – Encrypted password is stored in a in a separate file
  3. 284 – UID (User id)
  4. 284 – GID (Group id)
  5. vnStat Network Monitor – General information about the user
  6. /nonexistent – User’s home directory
  7. /usr/sbin/nologin – User’s login shell

How to just display a list of user names

Use the cut command as follows:
$ cut -d: -f1 /etc/passwd
OR use awk command:
$ awk -F':' '{ print $1}' /etc/passwd
Sample outputs:



How do I search for a given user name such as vivek

Use the grep command as follows:
$ grep '^userNameHere' /etc/passwd
$ grep '^vivek' /etc/passwd

Sample outputs:


How to use getent command to find out a list of users

To get entries from administrative database such as /etc/passwd use the getent command as follows:
$ getent passwd
$ getent passwd | more
$ getent passwd | grep vivek

A note about macOS Unix users

If you are using a macOS, try the following command to check list of users in Unix cli (open the Terminal app and type the following bash command):
$ dscl . list /Users
$ dscacheutil -q user
The dscl is a general-purpose utility for operating on Directory Service directory nodes.

How to find which Unix users are logged in and what they are doing

Type the following w command/who command:
$ w
$ who

How do I see available list of groups on my server?

Type any one of the following command:
$ more /etc/group
$ less /etc/group
$ grep vivek /etc/group

Display Unix account information using logins command

The logins command shows information about user and system accounts. All you have to do is type the following command:
$ logins

root            0       wheel           0       Charlie &
toor            0       wheel           0       Bourne-again Superuser
daemon          1       daemon          1       Owner of many system processes
operator        2       operator        5       System &
bin             3       bin             7       Binaries Commands and Source
tty             4       nogroup         65533   Tty Sandbox
kmem            5       nogroup         65533   KMem Sandbox
games           7       games           13      Games pseudo-user
news            8       news            8       News Subsystem
man             9       man             9       Mister Man Pages
sshd            22      sshd            22      Secure Shell Daemon
smmsp           25      smmsp           25      Sendmail Submission User
mailnull        26      mailnull        26      Sendmail Default User
bind            53      bind            53      Bind Sandbox
unbound         59      unbound         59      Unbound DNS Resolver
proxy           62      proxy           62      Packet Filter pseudo-user
_pflogd         64      _pflogd         64      pflogd privsep user
_dhcp           65      _dhcp           65      dhcp programs
uucp            66      uucp            66      UUCP pseudo-user
pop             68      mail            6       Post Office Owner
auditdistd      78      audit           77      Auditdistd unprivileged user
www             80      www             80      World Wide Web Owner
_ypldap         160     _ypldap         160     YP LDAP unprivileged user
hast            845     hast            845     HAST unprivileged user
tests           977     tests           977     Unprivileged user for tests
vivek           1001    vivek           1001    Vivek Gite
nobody          65534   nobody          65534   Unprivileged user

To get information about the password change and user account expiration times, run:
$ logins -a
Only find and display information about tom and jerry accounts:
$ logins -l userName
$ logins -l tom,jerry

Want to see Unix user accounts with no password? Pass the -p option:
$ logins -p
Finally, we can see information about each account’s home directory and shell such as csh, ksh, bash and more:
$ logins -x
$ logins -x -l vivek

vivek           1001    vivek           1001    Vivek Gite


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 4 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
4 comments… add one
  • nasewei Jan 2, 2018 @ 12:44

    what about “logins”-command?

  • Bibo Jul 18, 2020 @ 17:23

    Hi Vivek,
    I checked the logins cmd on Debian 10 (Buster) …
    it seems to me the cmd is here “lslogins” and the
    output looks a little bit different …

    • 🐧 Vivek Gite Jul 18, 2020 @ 18:15

      yes, that is expected as GNU/Linux is not Unix.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum