How to View Users in Ubuntu

Introduction

Ubuntu, like other Linux distributions, manages users and permissions through a structured system. Whether you are an administrator or a regular user, knowing how to view existing users on your Ubuntu system is essential for security and management.

Viewing All Users

Ubuntu stores user information in the /etc/passwd file. To list all users, run the following command in the terminal:

cat /etc/passwd

This command displays a list of users along with their associated system information. Each line represents a user account, formatted as:

username:x:UID:GID:comment:home_directory:shell

Alternatively, to display only usernames, use:

cut -d: -f1 /etc/passwd

Viewing Logged-In Users

To check currently logged-in users, use: who, or a more detailed output with: w. The w command provides information about user sessions, including login times and active processes.

Checking User Groups

To see groups a specific user belongs to, run:

groups username

For a more detailed view, use:

id username

Listing All System Users

System users are typically used for services and background processes. To filter human users from system accounts, use:

awk -F: '($3>=1000){print $1}' /etc/passwd

This command lists users with a UID of 1000 or greater, which usually indicates regular users.

Conclusion

Understanding how to view users in Ubuntu is crucial for system administrators, developers, and anyone managing a Linux environment. User accounts are at the heart of system security and resource management. They define who can access the system, what operations they are allowed to perform, and which files or processes they can interact with. In a multi-user system, even a single misconfigured account can pose a risk to stability or confidentiality.

Effectively managing and monitoring user accounts goes beyond just creating or deleting them. It involves regularly reviewing who has access to your system, identifying unused or suspicious accounts, and ensuring each user’s privileges are appropriate for their role. For example, granting administrative access to a user who only needs basic functions can increase the system’s vulnerability.