Управління користувачами

How to List Users in Ubuntu Linux VPS

How to List Users in Ubuntu Linux VPS
Linux is an excellent operating system that is widely used for team-based projects. So, it is good to have details about the system's users. It is easy to obtain details about system users in Ubuntu Linux VPS, and command-line inputs can help the system administrator to verify user permissions and activities in the system.

It is essential to learn these commands to be able to quickly see a list of users in your Ubuntu VPS system. This article shows you how to use the command-line to list users in Ubuntu Linux VPS.

How to List Users in Ubuntu Linux VPS: A Beginner's Guide

If you want to view all users in Linux Ubuntu VPS, you can use the /etc/passwd command, as local user details are saved in the “/etc/passwd” file. There are two ways to execute this command, as follows:

cat etc/passwd

Or

less etc/passwd

After executing the above command successfully, you will obtain an output that looks like this:

These output lines relate to the users. The number of lines depends on the number of users in the system.

Each line contains seven different fields that represent the details of a specific user. For example, the first line of the output is root:x:0:0:root:/root:/bin/bash, which represents:

Note that colons (:) are used for separating the values in the output.

Execute the following commands to see the names of the users:

cut -d : -f 1 /etc/passwd

Or

awk -F: ' print $1' /etc/passwd

How to View Groups in Ubuntu Linux VPS

You can also create groups by gathering several users and giving them some administrative permissions for the system. This option is beneficial for creating groups of users within the same system. The information about these groups will be saved in the Group folder. So, use the following command to view groups in the terminal.

less /etc/group

After executing the command successfully, you obtain an output like this:

Use the below command if you want to display the names of the groups:

cut -d : -f 1 /etc/group

How to List Users in Ubuntu Linux VPS Using the getent Command

The getent command is used for displaying entries from the database configured in the /etc/nsswitch.conf file. It covers the passwd database that can be used for querying the list of users. The getent command displays entries from databases configured in the /etc/nsswitch.conf file, including the passwd database, to query a list of all users.

Use the following command to execute getent in the terminal:

getent passwd

After executing the command, you will receive an output like this:

You can use awk or cut for printing the first field that contains the username:

getent passwd | awk -F: ' print $1'
getent passwd | cut -d: -f1

How to View Logged in Users with w Command

You can use the w command to list logged-in Linux Ubuntu VPS users. To use this command, type “w” in the terminal and execute it by hitting Enter.

After executing the command, you will receive an output that consists of various user information, such as login time, idle time, and remote host information. The details in the output are as follows:

Conclusion

This article covered in detail how to list users and user information in Ubuntu Linux VPS. These commands help system administrators to obtain user details that use a specific system and find out other important details about them. We hope the article was informative and comprehensive enough for your needs.

Remap your mouse buttons differently for different software with X-Mouse Button Control
Maybe you need a tool that could make your mouse's control change with every application that you use. If this is the case, you can try out an applica...
Microsoft Sculpt Touch Wireless Mouse Review
I recently read about the Microsoft Sculpt Touch wireless mouse and decided to buy it. After using it for a while, I decided to share my experience wi...
AppyMouse On-screen Trackpad and Mouse Pointer for Windows Tablets
Tablet users often miss the mouse pointer, especially when they are habitual to using the laptops. The touchscreen Smartphones and tablets come with m...