Back to course

46. Deep Dive: The `/etc/passwd` File Structure

Linux Basics: From Zero to CLI Hero

User Definitions

The /etc/passwd file is the central source of user account information, readable by all users.

Structure

Each line defines one user, with 7 fields separated by colons (:):

username:password_placeholder:UID:GID:comment:home_directory:shell

Example Line:

jsmith:x:1001:1001:John Smith:/home/jsmith:/bin/bash

Field Breakdown

  1. username: The login name (jsmith).
  2. password_placeholder: Since modern Linux uses shadow passwords, this field usually contains an x (or sometimes *), indicating the encrypted password is in /etc/shadow.
  3. UID: User ID number (1001).
  4. GID: Primary Group ID number (1001).
  5. comment: Full name or description.
  6. home_directory: The default starting directory (/home/jsmith).
  7. shell: The default shell program to run when the user logs in (/bin/bash). If set to /sbin/nologin, the user cannot log in interactively.