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

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 NumberField NameExampleMeaning
1️⃣UsernamerootThe login name of the user
2️⃣Password PlaceholderxIndicates the password is stored in /etc/shadow
3️⃣User ID (UID)0Unique ID for the user (0 = root, 1000+ = normal users)
4️⃣Group ID (GID)0The primary group ID for the user
5️⃣User Info (Comment Field)rootA description of the user (often empty or full name)
6️⃣Home Directory/rootThe default home folder for the user
7️⃣Login Shell/bin/bashThe default shell for the user

Example for a Normal User

rubyCopyEditjohn:x:1001:1001:John Doe:/home/john:/bin/bash
FieldValueMeaning
UsernamejohnThe login name of the user
Password PlaceholderxPassword stored in /etc/shadow
UID1001Unique ID (above 1000 = normal user)
GID1001Primary group ID (same as UID by default)
CommentJohn DoeOptional user description
Home Directory/home/johnDefault folder for storing files
Login Shell/bin/bashThe 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

Ravi Vishwakarma
Ravi Vishwakarma