The 4 Password Files

There are four files that handle user account information, like group membership and passwords.

/etc/passwd and /etc/shadow: User Passwords, Shell, etc.

What exactly does /etc/passwd file contain?

Entries of the form

dave:x:561:561:David Wright:/home/dave:/bin/zsh

There are seven fields separated by colons.

  1. Usernames
  2. An `x` in the password field to indicate that the password is stored in /etc/shadow
  3. User id
  4. Group id (Primary group)
  5. Name of user and other optional personal information
  6. User home directory
  7. User shell

You’ll see lots of entries made by the system.

What does an entry in /etc/shadow look like?

dave:Ep6mckrOLChF.:10063:0:99999:7:::

Eight fields separated by colons.

  1. Username
  2. Hashed password. If there is a blank entry `::`, then the user can log in without a password. If there is a `*`, the user account has been disabled
  3. The number of days since January 1, 1970 since the password was changed
  4. The number of days before the user can change their password, use `0` for any time
  5. The number of days before the user must change their password, use `99999` to effectively disable this requirement
  6. The number of days to warn a user before their password expires
  7. The number of days after the password expires that the user’s account will be disabled
  8. The number of days since January 1, 1970 when an account will be disabled

/etc/group and /etc/gshadow: User Group Memberships

What’s in /etc/group?

Entries of the form

docker:x:900:dave

Four fields separated by colons.

  1. Group name
  2. Password. Usually blank, the `x` here means that the password is stored in the /etc/gshadow file. You’ll most likely find it blank/disabled in that file.
  3. Group id
  4. Comma separated list of users who are members of the group (supplemental group membership)

What about /etc/gshadow?

docker:!!::dave

Four fields separated by colons.

  1. Group name
  2. Encrypted password, `!!` means no password has been set, and non-members cannot add themselves to the group using the newgrp command
  3. Group administrators: users who can add members using the gpasswd command
  4. Group members