1. Check all system users by displaying the contents of /etc/passwd. (Command required in output)

2 min read
Understanding the /etc/passwd
File
The
/etc/passwd
file stores user account information.Each line represents one user and contains seven fields separated by
:
.
Command to View It:
bashCopyEditcat /etc/passwd
Example Entry in /etc/passwd
rubyCopyEditroot:x:0:0:root:/root:/bin/bash
This can be divided into seven parts:
Field Number | Field Name | Example | Meaning |
1️⃣ | Username | root | The login name of the user |
2️⃣ | Password Placeholder | x | Indicates the password is stored in /etc/shadow |
3️⃣ | User ID (UID) | 0 | Unique ID for the user (0 = root, 1000+ = normal users) |
4️⃣ | Group ID (GID) | 0 | The primary group ID for the user |
5️⃣ | User Info (Comment Field) | root | A description of the user (often empty or full name) |
6️⃣ | Home Directory | /root | The default home folder for the user |
7️⃣ | Login Shell | /bin/bash | The default shell for the user |
Example for a Normal User
rubyCopyEditjohn:x:1001:1001:John Doe:/home/john:/bin/bash
Field | Value | Meaning |
Username | john | The login name of the user |
Password Placeholder | x | Password stored in /etc/shadow |
UID | 1001 | Unique ID (above 1000 = normal user) |
GID | 1001 | Primary group ID (same as UID by default) |
Comment | John Doe | Optional user description |
Home Directory | /home/john | Default folder for storing files |
Login Shell | /bin/bash | The shell used when logging in |
Special Users in /etc/passwd
root
(UID 0): Superuser with full control.daemon
,bin
,sync
(UID < 1000): System accounts for background tasks.nobody
(UID 65534): A low-privileged account for security reasons.
Filtering Specific Users
1. List Only Usernames
bashCopyEditcut -d: -f1 /etc/passwd
2. List Only Normal Users (UID ≥ 1000)
bashCopyEditawk -F: '$3 >= 1000 {print $1}' /etc/passwd
3. Check a Specific User
bashCopyEditgrep '^john:' /etc/passwd
Summary
/etc/passwd
contains user details in seven fields.Regular users have UID ≥ 1000, system users have UID < 1000.
Passwords are stored securely in
/etc/shadow
.The home directory and default shell define the user’s environment.
0
Subscribe to my newsletter
Read articles from Ravi Vishwakarma directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
