How to view system users on Ubuntu 20.04?

Overview

The management and configuration of users and groups is a crucial component of system administration. This responsibility includes keeping track of how each system entity can log in.

You can follow along on any current Linux distribution while we explore these ideas on a server running Ubuntu 20.04. By the end of this tutorial, you will be able to use some simple commands to examine all registered users and groups, how to view signed in users and manage your system administration.

Prerequisites

There are some prerequisites that need to be met before you begin:

  • Ubuntu equipped system

  • A regular user (non-root) having Sudo privileges

  • Internet connection

How to view available Users?

Linux stores all information about user registrations in the passwd file located at /etc/passwd.

  • To access the contents of the file, open a terminal and type the following command:

less /etc/passwd

The script returns a list that looks like this:

Each row is divided into fields. These fields are delimited by a colon (:).

For Example: root:x:0:0:root:/root:/bin/bash

  • To get the list of only usernames, use the following special cut command:

cut -d : -f 1 /etc/passwd

Root is the administrative user present on the top of the list, which you surely already know. The user that you are now logged in as might be visible at the end of the list.

How to find which users are logged in?

  • The w command makes it simple to see who is logged in right now, when they logged in, and what commands they are now running:

w

Information about the system uptime is found on the first line. Who is logged in is listed in the following lines.

  • who command is another choice that offers comparable details (the results are not as detailed as the w command).

Conclusion

Several users can log in to the same machine simultaneously, making Linux the ideal operating system for team-based work. For better system administration, it is crucial to understand how to manage users because of this.

Now that you know how, you can locate the location of the user, group data storage on your server and see who currently is logged in.

Last updated