Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills
24.01.2025

Ability to view all available users in Linux

View Linux Users on Your AlexHost VPS: Quick and Easy Methods

Why check Linux users? Managing users on your AlexHost Linux VPS is crucial for security and administration, especially for WordPress, Laravel, or other CMS setups. Knowing who’s registered helps you control access, troubleshoot issues, and keep your server locked down. This guide breaks down simple commands to view user info, optimized for AlexHost’s Ubuntu-based VPS environment with root access.

Method #1: Checking with the /etc/passwd file

One of the main sources of user information in Linux is the /etc/passwd file. This file contains records of users, their IDs, home directories, and shells used. You can use the cat or less command to view the contents of this file. Each line of the file represents a user record, with fields separated by colons. An example is shown here:

 

Method #2: Using the getent command

The getent command is used to retrieve records from databases, including user information from the /etc/passwd file. This allows you to view the list of users more conveniently.

getent passwd

Method #3. Using the cut command to extract usernames

If you only need to extract usernames, you can use a combination of Cut and awk commands.

getent passwd | cut -d: -f1

This command uses the colon delimiter in the /etc/passwdfile to extract the first field. This in turn contains the usernames that are displayed to you.

 

Method #4. Using the awk command to selectively display information

When you are working with your server, you may want to limit the output to information about specific aspects of a user; you can use awk. For example, the following command will display the names and home directories of all users:

getent passwd | awk -F: '{print "Username: " $1 "\t Home Directory: " $6}'

Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills