Last Updated on December 8, 2018 by admin

In this tutorial, We are going show you the various commands to list users in Linux. It’s always fun to play with Linux command.

List Users In Linux Using Command Line

In Linux, users information is stored in /etc/passwd file. In this file, each line contains the information of each user account. Let’s open this file and get the details of users in Linux.

Linux commands tutorial

Run the following command to list users in Linux using command line.

$ cat /etc/passwd

Run the following command to display up one line at a time.
$ more /etc/passwd

Run the following commands to display one page(one screen) per time.

$ less /etc/passwd

Now, Run the following command to display only the username or to only List user names on Linux. We are using awk command to list only usernames:

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

Alternative command:

$ cut -d: -f1 /etc/passwd

Sample outputs:


You can also use getent command to get a list of all Linux users. Run the following command:

$ getent passwd
$ getent passwd | grep tom

You can even use awk or cut to display usernames:

getent passwd | awk -F: '{ print $1}'
getent passwd | cut -d: -f1

Check whether users exits or not:

Run the following command to check whether a user exists in Linux.

getent passwd | grep omgfoss

Check the number of user accounts in Linux.

Run the following command to check the number of user accounts in Linux.

getent passwd | wc -l




We have only mentioned some of the primary command to list Linux users as other further command option to list Linux users will be mentioned in upcoming articles. This post is intended for the beginner level of Linux users. We will regularly update our articles regarding various Linux commands.

READ More Relevant Stuff:  9+ Best Linux Screen Recorder On Ubuntu 20.04 LTS

Note: Let us know if there is any errors in this post.

Leave a comment

Your email address will not be published. Required fields are marked *