How to List Users in Linux


Linux provides a robust user management system that allows administrators to create, manage, and organize user accounts efficiently. Knowing how to list users is a fundamental skill for system administrators, as it enables them to monitor user activity, allocate resources, and ensure system security. In this article, we’ll explore various commands and methods to list users in Linux.

/etc/passwd file

One of the primary sources of user information in Linux is the /etc/passwd file. This file contains entries for all user accounts on the system. Each line in the file represents a user and contains crucial information like the username, user ID (UID), group ID (GID), home directory, and the default shell.

To list all users from the /etc/passwd file, you can use the cat command along with cut or awk to filter the relevant information. Here’s an example:

cat /etc/passwd | cut -d: -f1

Or using awk:

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

/etc/group file

The /etc/group file stores information about user groups on the system. You can use similar commands to list groups and their members.

cat /etc/group | cut -d: -f1

Or using awk:

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

/etc/shadow File

The /etc/shadow file contains encrypted password information for user accounts. While the passwords are encrypted, this file can be explored for other user-related details like the last password change, password expiration, and account lock status:

cat /etc/shadow

Note: Access to /etc/shadow is typically restricted to root for security reasons.

getent command

The getent command is a versatile tool that retrieves entries from various databases, including user and group information. To list all users, you can use:

getent passwd | cut -d: -f1

Or using awk:

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

The w Command

The w command provides information about currently logged-in users, including their usernames, terminal, remote host, login time, and activity. To list users currently logged in:


The who Command

Similar to the w command, the who command provides information about users who are currently logged in. It displays details such as username, terminal, date, and time.


The users Command

The users command provides a simple list of usernames for users currently logged in.


This command is concise and provides a quick overview of who is currently using the system.

See also  How to Install Docker on Ubuntu

Graphical User Interface (GUI) Tools

For systems with a graphical user interface, tools like the “Users and Groups” utility or the “System Settings” provide a user-friendly interface to manage and view user information.


Listing users in Linux is a fundamental task for system administrators and users alike. The commands mentioned in this article offer various ways to retrieve information about users, each serving different purposes. Understanding these commands empowers users to manage access, monitor system activity, and maintain the security of their Linux systems.

See more:

Leave a Reply

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