List Users In Linux Operating Systems [How To ]

How To List Users In Linux

Insight:How To List Users In Linux Operating Systems

This tutorial is intended for the beginner level of Linux users who are right at the phase of learning basics of Linux. Here, We will talk about various 3 ways to list users in Linux based operating system

How To list users in Linuxx


How To List Users In Linux Operating Systems

Let’s check methods to list users in Linux.

1. Method To List Users In Linux Using less /etc/passwd

Well, This method will let you see the list of users in your Linux operating system. It list out the users details stored in the system. /etc/passwd stores the details of every registered user that has access to a system.

The /etc/passwd file is a colon-separated file that contains the following information:

  • User Name
  • Encrypted Password
  • User ID number (UID)
  • User’s group ID number (GID)
  • Full name (GECOS)
  • User home directory
  • Login shell

Important thing that you should remember is that the /etc/passwd file is owned by the root user but it can be readable by all the users, but only the root user has writable permissions to this file.

If you get confused with normal users and system users then you should look over the UID. Normal user has UID greater or equal to 1000 and users with UID <1000 are system users of the system.

2. List Linux users with compgen

Another method to list Linux users is with compgen command. This is a simple command which let you to list all the usernames. To list users without any additional information, you can use the compgen command with -u option.

READ THIS ALSO  How To Get Linux System And Hardware Details In Linux

3. List Linux users with Getent command

This command command displays entries from databases which is configured in /etc/nsswitch.conf Run the following command to list Linux users.

 sudo getent passwd

To list all groups in Linux. Run the following command.

sudo getent group

To search group with specific username. Run the following command (Here omgfoss is the username):

$ getent group | grep omgfoss


Let us if there is something confusing and missing in this tutorial post to list users in Linux.