How to List Users in Linux
Administering and securing a Linux system requires careful monitoring and management of users. Knowing who is using your system and what actions they are performing is critical to maintaining server and computer security and efficiency in Linux.
This guide will cover various methods to check users in Linux, including using the terminal and the graphical interface (specifically, the Gnome shell). The methods discussed here will help you gather information about user accounts, their activities, login history, and more.
There are several ways to list user accounts. Below, we will outline two sections that explain how to access the list of Linux users via the terminal and the graphical interface.
Terminal Copy link
In this section, we'll explore methods to display Linux users using the command line.
/etc/passwd File Copy link
The /etc/passwd file contains information about registered users in the system. Each line in this file represents one user account, including its name, password, user ID (UID), group ID (GID), additional user info (GECOS), home directory, and login shell.
To view the contents of the /etc/passwd file, you can use the following command:
cat /etc/passwdYou can also open this file in any text editor (e.g., nano, vim).
For example, if you are using a cloud server from Hostman with a non-admin user, the /etc/passwd file might look like this:

As shown above, the passwords are represented by x for security reasons. They are actually stored in a different file, /etc/shadow.
If you only need a list of Linux users by their names, use the following command:
sed 's/:.*//' /etc/passwd
who Command Copy link
The who command shows a list of active users, including their names, the terminals they logged in from, login date and time, and the IP address if available. To use it, type:
whoAn example output might look like this:

If you only need the names of the users currently logged into the system through the terminal or via remote connections, enter:
usersThe result of the users command is shown below:

The main difference between who and users is the level of detail. If you need more information, who is the better option. If you simply want a list of active users, users is more concise and convenient.
w Command Copy link
The w command provides a detailed list of active users, including their names, terminals, activity (what they are currently doing), login time, and system load. To get this list, enter w in the terminal:
w
last Command Copy link
The last command lets you view users' login history, including information about the dates, times, and sources of their logins. This tool helps monitor user activity and identify potential security threats.
To use it, type:
lastThe result will look like this:

lastlog Command Copy link
The lastlog command provides information about the last login times of users. This can be helpful for monitoring user activity on your system.
To use this tool, enter:
lastlogThe output will be similar to this:

Graphical Interface Copy link
For those who prefer using a graphical interface instead of the terminal, we'll explain how to check Linux users using graphical tools. This section focuses on Gnome, as utilities for listing users are no longer supported in KDE Plasma.
In systems with the Gnome graphical interface, there are at least two ways to access the list of Linux users.
"Users" Menu Copy link
To use the "Users" menu, go to the system settings. Click "Overview," type "Settings" in the search bar, and select the available tab.
Next, in the window that opens, select the "Users" tab and click the "Unlock" button in the upper right corner. This will allow you to access all available functions, including adding new accounts, listing existing ones, and editing them.
At the top, you'll see existing users, and below, their details and settings.
"Users" Utility Copy link
In addition to the tool mentioned above, you can also install the "Users" utility in Gnome. To do this, enter the following command in the terminal:
sudo apt install gnome-system-toolsThis command works for distributions using the apt package manager. In other systems, the command may vary (dnf for Fedora, pacman -S for Arch Linux, etc.).
After downloading the utility, you can launch it. Go to the search menu as shown earlier, and type "Users." Then, select the newly installed utility.
In the window that opens, you can view and edit the list of accounts, as well as modify each account's settings (account type, password, and other additional parameters).
Summary Copy link
To list users in Linux, you can use one of the methods mentioned earlier. If you interact with the system via the terminal, the following methods and commands will be helpful:
-
The
/etc/passwdfile contains information about existing users. -
The
whocommand shows a list of active users and details about them. -
The
wcommand provides a detailed list of active users, including their current activities. -
The
lastcommand shows login history, allowing you to see when and from which devices users logged in. -
The
lastlogcommand displays information about users' last login times.
If you use Linux with the Gnome graphical interface, choose one of these solutions:
-
The "Users" menu.
-
The "Users" utility.
Understanding who logs into your system and what actions they are performing helps to promptly detect issues and ensures more effective system management. Select the method and tools that best suit your needs from this guide for your Linux system.
And if you’re looking for a reliable, high-performance, and budget-friendly solution for your workflows, Hostman has you covered with Linux VPS Hosting options, including Debian VPS, Ubuntu VPS, and VPS CentOS.