Wesbytes Knowledge Base

Search our articles or browse by category below

Guides On How to List Users In A Linux Based VPS

Last modified: July 2, 2022
You are here:
Estimated reading time: 2 min

A VPS server is popular among tech research organisations and development communities and is appropriate for team-based projects. As a result, it is crucial to protect your personal data on a VPS because VPS are frequently used by several users concurrently. To help us protect our data, we may view a list of the users on a VPS and their permissions as well as their activity. We’ll show you how to list users on a Linux-based VPS in this article. The Ubuntu OS is the Linux distribution used in this manual.

View All Users

A VPS server is popular among tech research organisations and development communities and is appropriate for team-based projects. As a result, it is crucial to protect your personal data on a VPS because VPS are frequently used by several users concurrently. To help us protect our data, we may view a list of the users on a VPS and their permissions as well as their activity. We’ll show you how to list users on a Linux-based VPS in this article. The Ubuntu OS is the Linux distribution used in this manual.

less /etc/passwd

The output will be a list of users’ information such as the following output.

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
...

The fields of data are separated by colons, where the format goes by the following way.

user_login_name:password:userID:groupID:comment_field:home_directory:user_shell

The user’s login name is “user_login_name,” and the password for that specific user is “password.” It should be noted that the password is only a placeholder; the real password is kept in another file. The “userID” and “groupID” are the individual identifiers for each user and are each unique.

The user’s brief description is found in the “comment_field” field, their home directory is found in the “home_directory” field, and their login shell is found in the “user_shell” field. However, you can use this command if all you want to see is the names of the users.

cut -d : -f /etc/passwd

View Groups

It is possible to create groups in Linux too, where you can gather a number of users and grant them certain privileges in the system. The group information is stored in a different file called group, which can be found at “/etc/group”. Similarly to view users, first you have to open the terminal, then access the content using the following command line.

less /etc/group

The output for each line should be something similar to this.

Root:x:0
Daemon:x:1:
...

Also, similarly to the users, you can choose to only view the group name using the following command.

cut -d : -f 1 /etc/group

View Active Users

To list all logged-in users, just open the terminal and run “w”.

w

You will be able to see how many users are online and several fields. To list down all the fields.

  • User – refers to the username.
  • TTY – refers to the terminal name.
  • From  – refers to the name of the remote host.
  • Login@ – refers to the login time.
  • Idle – refers to the duration of idle time.
  • JCPI – refers to the time used by processes attached to the terminal name.
  • PCPU – refers to the time processed displayed in the WHAT field.
  • WHAT – refers to the user’s current process.

There is another command that works the same way as “w”, which is the “who” command, however, it will show a less detailed version of it.

Was this article helpful?
Dislike 0
Views: 35