Don’t know how to list users on Ubuntu Linux VPS? Fret not as that is what we are going to discuss here in detail. Ubuntu is among the top-rated Linux distributions with millions of users - a mix of students, professionals, developers, and whatnot - all around the world benefitting from the same.
Although it is a desktop-friendly Linux distro that is sort of equivalent to Windows from Microsoft, Ubuntu offers excellent development capabilities. Moreover, Ubuntu is available in 3 different variants:
- Desktop - Specialized for generic desktop usage.
- Server - Specialized for server use.
- Core - Specialized in IoT and robotics.
As you can see from above, Ubuntu Server focuses on server usage. It has gained quite a good momentum over the past few years. With the increase in the Virtual Private Server (VPS) trend, Ubuntu has become more important for server use than ever.
Before getting started with this guide on how to list users on Ubuntu Linux VPS, it is imperative for you to know why exactly you might need to view the list of users on your Ubuntu Linux VPS. This is exactly what is explained in this next section.
Why You Might Need to Access the User List on Linux Ubuntu VPS?
As a system admin, you often need to review and manage the permissions of all the users and groups that have some level of access to your VPS. By listing users and groups, you can visualize the processes (or activities) that they are running on your VPS along with their permission levels to access data.
So now that you know why you might need to list users on a Linux Ubuntu Virtual Private Server, it’s time for you to become familiar with the process that will let you do the same.
Listing Users on an Ubuntu Linux VPS
To list the users active on your VPS, you need to first establish a connection to your server. You can do this using a Secure Shell SSH. Just keep in mind that you’ll need the PuTTy SSH client to access your VPS if you are on Windows.
On the other hand, if you are on a Mac or Linux, the built-in terminal will get the job done. After getting into your VPS system, what you need to do is to simply run the following command:
After running the command, you will be able to see a list similar to the one shown below:
This list shows all the users currently active on the VPS with the first entry on the list specifying information about the root user. Each line on the list corresponds to a single user.
Let’s breakdown the information that each line represents by taking into consideration the first entry on the list i.e.:
You’ll notice that there are 7 different fields in the line that are separated from each other using: (colons). Here is what each field represents:
- root - Username
- x - Encrypted Password
- 0 - User ID
- 0 - Group ID
- root - Full Username
- /root - Home Directory of the User
- bin/bash - Shell through which the user has accessed the server.
If you examine the other entries on the list, you will observe that the second field within each entry is represented with x. It is because the password of each user is encrypted and cannot be shown here. Thus, x is used as a placeholder for the field.
Also, you should notice that the User ID and Group ID assigned to each user are unique.
- Bonus Tip - If you want to view only the name of the users, you need to run another command, which is as follows:
cut -d : -f 1 /etc/passwd
Listing Groups on Ubuntu Linux VPS
Apart from listing all the users, you can also get the list of groups active on your Ubuntu Linux VPS. In general, a group is a collection of users having the same level of permissions. Groups make it easier for you, as an administrator, to control users in batches.
To view all the groups active on your VPS, you simply need to run the following command on your SSH client:
You will get the list of groups on your VPS, which looks something like this:
- Bonus Tip - You can also restrict the group list to display only the name of the groups by running the following command:
cut -d : -f 1 /etc/group
Getting Information About the Users Logged into the System
It is also possible for you to get information about the users that are currently logged in to the VPS system. For that, all you need to do is to run a simple command on the SSH client, which is, merely, the letter w.
After executing the command, you will be able to see a list of all the users currently accessing the VPS system. In the screenshot ahead, there is only a single active user (root):
There are a total of 8 columns, with each column providing a specific piece of information. Here’s the information that you’ll get:
- USER - Username.
- TTY - Terminal name of the VPS server from which the user is accessing the system.
- FROM - Hostname of the user.
- LOGIN@ - Login time of the user.
- IDLE - Idle time of the user.
- JCPU - Total time used by processes linked with the TTY.
- PCPU - Total time used by processes linked with WHAT.
- WHAT - Current process run by the user.
Difference Between System User and Normal User
Whether you are using Linux VPS to host games or using it for development purposes, there’s one important thing that you need to know:
The difference between the system user and a normal user.
- System User
Consider the system user as the supreme user that can control and manage other users accessing the system. In other words, the system user has the authority to create and give permissions to new users, i.e. normal users.
Whenever you install Ubuntu, the OS automatically creates the system user. When you list users on your Ubuntu Linux VPS, you will notice the first user on the list as root, which is the system user by default.
- Normal User
A normal user is the one having limited privileges and system access. The permissions of a normal user are decided by the system user.
By now, you will be able to successfully list users on an Ubuntu Linux VPS. Therefore, you will be able to better manage your Linux Ubuntu Virtual Private Server by tracking user activity in real-time.
Want to share your experience or report something that isn’t working? Do the same via the dedicated comments section below. Until next time!