How to List All Users in Linux

Linux user management is a fundamental skill for system administrators. One of the essential tasks in this domain is listing users on your Linux system. Knowing how to do this can be incredibly useful for system monitoring, access control, and security. In this guide, we’ll explore various methods to list users in a Linux environment.

Understanding User Management in Linux

Before we dive into user listing, let’s briefly understand user management in Linux.

User Types

Linux has two primary types of users:

  • Superusers (Root): These users have the highest level of administrative access, often denoted by the username “root.”
  • Regular Users: Regular users are standard accounts created for day-to-day activities. They don’t have system-level privileges like the root user.

User Accounts

User accounts are essential for system security and access control. They help you track who can log in and interact with your system. Now, let’s move on to listing these users.

Basic Commands for Listing Users

Here are some basic commands you can use to list users in Linux:

1. who

The who command displays information about users who are currently logged in, along with details like terminal, login time, and originating IP addresses. To use it, open your terminal and type:

Linux who command

2. w

The w command provides detailed information about logged-in users, including their terminal, username, activity, and more. It’s an extension of the who command. To use it:

w Linux command

3. users

The users command displays a simple list of usernames of users currently logged in. It’s straightforward and useful:

users Linux command

These commands are excellent for seeing who’s currently active on your system. However, they won’t provide a comprehensive list of all users, including those who are not currently logged in.

Listing Local Users

To list all local users on your system, you can use the /etc/passwd file in combination with command-line tools like cut, grep, or getent. Here’s how you can do it:

cut -d: -f1 /etc/passwd

This command uses the colon (:) as a delimiter to extract usernames from the /etc/passwd file.

List Local Users

Listing All Users, Including System Users

To list all users, including system users, you can use the /etc/passwd file along with commands like cat, awk, and cut. Here’s how to do it:

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

This command combines the cat and cut commands to extract all usernames from the /etc/passwd file.

List All Users Linux

Listing Users from Specific Groups

To list users who belong to specific groups, you can use the getent command along with awk. For example, to list users from the “sudo” group:

getent group sudo | cut -d: -f4

This command retrieves the “sudo” group details and extracts the list of users.

List Users from a Group in Linux

Listing Users with Specific Attributes

You can also list users with specific attributes, such as those who haven’t logged in for a certain period. The lastlog and chage commands are handy for this purpose.

Using ‘lastlog’

The lastlog command lists users who haven’t logged in. For instance, to list users who haven’t logged in for the past 90 days:

lastlog -b 90

This command displays a list of users and their last login information.

List Users with lastlog in Linux

Using ‘chage’

The chage command allows you to view and change user password aging information. To list users with aging information:

chage -l username

Replace “username” with the actual username.

List Users with chage command in Linux

Listing Users in a More User-Friendly Format

To present the user list in a more user-friendly format, you can use commands like awk, sed, and column. For example, to format the list as a single column:

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

This command utilizes cut to extract usernames and column to format them neatly.

List users with cut command in Linux and list them as column


Understanding how to list users is a fundamental skill for Linux administrators. It’s a key aspect of system monitoring, access control, and user management. By using the methods and commands outlined in this guide, you can efficiently list users and gain valuable insights into your Linux system.

Remember, user management goes beyond just listing users; it involves creating, modifying, and deleting user accounts, which

Recent Articles

Related Stories

Stay on op - Ge the daily news in your inbox