User management is an important part of Linux administration, so it’s essential to know about all the user accounts on a Linux system and how to disable user accounts, etc. In this guide, we’ll show you how to list the current users via command line and GUI. This will include a GNOME desktop environment as well as KDE.
In this tutorial you will learn:
- How to list users via command line
- How to list users on GNOME GUI
- How to list users on KDE GUI
Category | Requirements, Conventions or Software Version Used |
---|---|
System | Any Linux distro |
Software | N/A |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
List users via command line
User information is stored in the system’s /etc/passwd
file. Looking at the contents of this file will allow us to see a list of the users on a system. Each user will take up one line in the file.
Open a terminal on your system and type the following command to list all users:
$ cat /etc/passwd
At the beginning of every line is the name of a user account. In total, there are seven fields of data which are separated by colons. To help you comprehend this file, here’s what each field means:
- User name
- Encrypted password (
x
indicates the password is stored in/etc/shadow
- User ID number
- User group ID number
- User’s full name
- Path to user’s home directory
- Default shell
Since this output is way too much if we only need the names of the users, we can use the awk command to display only the user names of the accounts.
$ awk -F: '{ print $1}' /etc/passwd
To check for a specific user, you can always pair this with the grep command:
$ awk -F: '{ print $1}' /etc/passwd | grep root
List users on GNOME GUI
To see a list of users in GNOME, you’ll need to install the gnome-system-tools
package. You can install it by typing the following command in terminal if you’re running Ubuntu or another Debian based distro:
$ sudo apt install gnome-system-tools
Arch Linux and Manjaro:
$ sudo pacman -S gnome-system-tools
$ sudo dnf install gnome-system-tools
Once it’s installed, you’ll be able to open the Users & Groups application.
This application will list the normal users on the system, but it doesn’t list system users.
List users on KDE GUI
KDE has a built in user management menu. You can simply search for it in the app launcher.
The list of users will be shown here.
Conclusion
In this article, we saw how to list users on a Linux system. We learned about a command line method, which was proven ideal for listing all normal and system users, but we also learned how to do it in GUI via GNOME and KDE desktop environments. The GUI methods are effective but they don’t list system users. You should pick whichever method is easier for you and most appropriate for the situation at hand.