December 5, 2019
December 5, 2019
In this article, we will show you how to list users on Ubuntu VPS. By the end of this tutorial, you’ll be able to perform some basic commands to view all registered users and groups to manage your system administration. So, without further ado, let’s get started.
Linux is popular among tech research groups and development communities because it is suitable for team-based projects. This means that oftentimes, a Linux-based system is used by multiple users at the same time.
For that reason, managing these users and groups is a day-to-day task. System administrators can take advantage of Ubuntu’s complete features to control how users and groups interact with the system.
For instance, you can grant certain users and groups to access specific files and folders. What’s more, you can adjust configuration and administrative rights to modify your system and secure your data by preventing any harmful anonymous process.
However, before configuring those settings, it is better to learn how to list users on Ubuntu VPS or server. The reason is simple: you will need to see their permissions and activities to verify every operation on your machine.
Do note that since we will list users on Ubuntu VPS, we have to use the command line to access it. You can work with the terminal shell (Linux and macOS) or PuTTY (Windows). If you’re a Hostinger user, the login credentials are located in the hPanel’s Servers tab.
We are going to divide this tutorial into three parts — viewing all users, viewing groups, and viewing logged in users.
Linux stores all the information about user registrations in a file called passwd, which is located at /etc/passwd.
root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh …
In the output above, each line corresponds to a user. The number of lines will depend on the number of registered users.
Each line contains seven fields that are separated by colons (:). These fields hold specific information about a particular user.
Let’s take a look at the first line:
Here are the meanings of each field, from left to right:
If you only want to view the name of the users, you can run this special command:
cut -d : -f 1 /etc/passwd
In Linux, you also have the option to create groups. You basically gather several users and grant them joint privileges or access. It is particularly useful if multiple teams are using the same system.
Unlike users, the group information is stored in a file named group that can be found at /etc/group.
Root:x:0: Daemon:x:1: Bin:x:2: Sys:x:3: . . .
Notice that the group names are exactly the same as the name of our users. This is the result of user private groups (UPG), a scheme employed by Linux where each user will have their own private group.
Just like the previous one, it is possible to view the group names only:
cut -d : -f 1 /etc/group
To list logged in users, simply type the following letter in your terminal:
Besides showing the active users, the command also provides some additional information like login time, remote host, and idle time. The full results will look like this:
Let’s breakdown the results of the w command:
Alternatively, there is another command that performs a similar function to w:
However, the results won’t be as detailed as the w command:
root pts/0 2019-10-21 10:02
Linux is a perfect OS for team-based projects because many people can log in to the same system. Due to this nature, it is important to learn how to manage users for better system administration.
The first lesson you need to know is to list the registered users, which will be useful to verify all operations and protect your data.
In this guide, we have shown you how to list users on Ubuntu VPS using simple commands. In addition, you’ve also learned how to view all groups and monitor every logged-in user.
Good luck and be sure to check other VPS tutorials!