How to View Users in Ubuntu
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.
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
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.
To see groups a specific user belongs to, run:
groups username
For a more detailed view, use:
id username
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.
Understanding how to view users in Ubuntu is crucial for managing access and maintaining security. By using these commands, you can efficiently monitor user activity and system accounts on your machine.