How to Display Users in Linux
When you work with Linux, knowing how to display users is a key skill. Whether you’re managing a server or just curious about who has access to your system, you’ll want to see a list of users quickly and clearly. I’ll guide you through the most common and useful methods to display users in Linux, so you can find the information you need without hassle.
We’ll cover commands that show all users, currently logged-in users, and even details about user accounts. By the end, you’ll feel confident using these tools for everyday Linux tasks or troubleshooting. Let’s dive in and explore how to display users in Linux step by step.
Understanding Linux Users
Linux is a multi-user operating system, which means many people can have accounts on the same machine. Each user has a unique username and associated information stored in system files. Knowing who these users are helps with system security and management.
Here are some key points about Linux users:
- User accounts are stored in the
/etc/passwdfile. - Each user has a unique user ID (UID).
- Users can be active (logged in) or inactive.
- System users exist for running services and are not typical human users.
Understanding these basics helps you interpret the user information you’ll find with commands.
How to Display All Users in Linux
If you want to see every user account on your Linux system, the easiest way is to look at the /etc/passwd file. This file contains all user information in a simple text format.
Using the cat Command
You can display the entire file with:
cat /etc/passwd
This shows lines like:
root:x:0:0:root:/root:/bin/bash
john:x:1001:1001:John Doe:/home/john:/bin/bash
Each line represents a user and contains fields separated by colons:
- Username
- Password placeholder (usually
x) - User ID (UID)
- Group ID (GID)
- User description or full name
- Home directory
- Default shell
Listing Only Usernames
If you want just the usernames, use cut to extract the first field:
cut -d: -f1 /etc/passwd
This command lists all usernames, including system and regular users.
Filtering Human Users
System users usually have UIDs below 1000. To list only regular users, you can filter by UID:
awk -F: '$3 >= 1000 {print $1}' /etc/passwd
This shows usernames with UID 1000 or higher, which are typically human users.
Displaying Currently Logged-In Users
Sometimes, you want to know who is logged in right now. Linux offers several commands for this.
The who Command
The simplest way is:
who
This lists logged-in users with their terminal, login time, and sometimes IP address.
Example output:
john pts/0 2026-04-15 09:12 (:0)
mary pts/1 2026-04-15 09:15 (192.168.1.10)
The w Command
The w command provides more detail, including what users are doing:
w
It shows username, terminal, login time, idle time, JCPU, PCPU, and current command.
The users Command
For a quick list of logged-in usernames only, use:
users
This outputs usernames separated by spaces, like:
john mary
Checking User Details with id and finger
To get detailed information about a specific user, Linux provides commands like id and finger.
Using id
The id command shows the user’s UID, GID, and group memberships:
id john
Output example:
uid=1001(john) gid=1001(john) groups=1001(john),27(sudo)
This helps you understand user permissions and group access.
Using finger
The finger command gives more user info, including full name, home directory, shell, and last login:
finger john
If finger is not installed, you can add it with your package manager (sudo apt install finger on Debian-based systems).
Using Graphical Tools to Display Users
If you prefer graphical interfaces, many Linux desktop environments offer user management tools.
GNOME Users Settings
In GNOME, you can open Settings > Users to see a list of users and manage accounts.
KDE User Manager
KDE provides a user management tool called User Manager or KUser for viewing and editing user accounts.
These tools are handy for casual users or administrators who prefer GUI over command line.
Managing User Sessions and History
Knowing who is logged in is useful, but sometimes you want to see user login history.
Using last
The last command shows recent login sessions:
last
It lists users, login times, logout times, and session duration.
Using lastlog
To see the last login time for all users, use:
lastlog
This helps identify inactive accounts or security issues.
Summary Table of Commands to Display Users
| Command | Purpose | Example Usage |
cat /etc/passwd | Show all user accounts | cat /etc/passwd |
cut -d: -f1 | List usernames only | cut -d: -f1 /etc/passwd |
awk | Filter users by UID | awk -F: '$3 >= 1000 {print $1}' /etc/passwd |
who | Show currently logged-in users | who |
w | Show logged-in users with details | w |
users | List logged-in usernames quickly | users |
id | Show user ID and groups | id username |
finger | Detailed user info | finger username |
last | Show login history | last |
lastlog | Show last login times for all users | lastlog |
Tips for Displaying Users Securely
When displaying user information, keep security in mind:
- Avoid sharing sensitive user details publicly.
- Use
sudoonly when necessary to access system files. - Regularly check for inactive or unknown users.
- Monitor login history for suspicious activity.
These practices help keep your Linux system safe and well-managed.
Conclusion
Displaying users in Linux is straightforward once you know the right commands. Whether you want to see all users, check who is logged in, or get detailed user info, Linux provides simple tools like cat, who, id, and more. Using these commands helps you manage your system effectively and securely.
Remember, understanding user accounts is key to good Linux administration. With these methods, you can quickly find the user information you need and keep your system running smoothly. Try these commands yourself and explore how they fit your workflow.
FAQs
How do I list all users on my Linux system?
You can list all users by viewing the /etc/passwd file with cat /etc/passwd or extract usernames only using cut -d: -f1 /etc/passwd.
How can I see who is currently logged in?
Use the who command to see logged-in users, or w for more detailed information about their activity.
What command shows a user’s groups and ID?
The id username command displays the user ID, group ID, and groups the user belongs to.
How do I check the last login time of users?
Use the lastlog command to see the last login times for all users on your system.
Is there a graphical way to view users in Linux?
Yes, desktop environments like GNOME and KDE offer user management tools in their settings for viewing and managing users graphically.
