- How Linux stores password data
- Where default password policies are defined
- How to inspect and change password aging for existing accounts
- How to set account expiration and force password resets
How Linux stores passwords
- Password hashes are stored in
/etc/shadow. These are hashed values — not plaintext — to protect confidentiality. - Only privileged users (typically
root) can read/etc/shadow.
The
/etc/passwd file contains account metadata (username, UID, GID, shell, home directory) but not the password hashes; the hashes live in /etc/shadow, which has restricted permissions.Default password policy for new accounts
When you create a new user, Linux assigns default password aging values from/etc/login.defs. This file controls:
- Maximum password age (
PASS_MAX_DAYS) - Minimum days between password changes (
PASS_MIN_DAYS) - Minimum password length (
PASS_MIN_LEN) - Warning period before password expiration (
PASS_WARN_AGE)
/etc/login.defs affects users created after the change.
Managing existing accounts with chage
Usechage to view and modify password aging and account expiration for existing users. chage supports both non-interactive flags and an interactive prompt.
Common chage usages are summarized below.
Note: Regular users can change their own password with
passwd. Only root can change other users’ passwords or change other users’ aging settings.
Quick reference: chage examples and expected output
Createuser1, set a password, then configure aging:
Interactive mode example
chage without flags enters interactive mode and prompts for values. This is useful for manual auditing and ad-hoc policy changes.
Where do the default values come from?
New-user defaults are taken from/etc/login.defs. Look for these parameters:
PASS_MAX_DAYS to 30 in /etc/login.defs, any users created afterwards will inherit MAX_DAYS=30.
Example: create user3 after changing defaults
PASS_MAX_DAYS = 30 in /etc/login.defs was applied to the new account.
Best practices and operational notes
- Only privileged users (root) can read
/etc/shadowand modify other users’ password settings. Use least privilege for management tasks. - Use
chage -l <user>regularly to audit user password aging configuration. Automate checks where possible. - Update
/etc/login.defsto enforce default policies for accounts created in the future, and applychageto existing accounts to make policies consistent across your environment.
- Require complex passwords and enforce minimum length (
PASS_MIN_LEN) in/etc/login.defsor via PAM modules. - Combine expiration policies with account lockout rules from PAM (e.g.,
pam_faillock) to reduce brute-force risk. - Document policy changes and keep a change log for compliance requirements.
Recap
- Password hashes are stored in
/etc/shadowwith restricted access. - Default password aging for new users is defined in
/etc/login.defs. - Use
chageto modify expiration rules and force password resets for existing users. - Use
passwdfor password changes; regular users can change their own password, whilerootcan change any account’s password. - Combine
/etc/login.defs,chage, PAM configuration, and auditing to enforce password policies and manage account lifecycle effectively.
Links and references
- chage manual: https://man7.org/linux/man-pages/man1/chage.1.html
- passwd manual: https://man7.org/linux/man-pages/man1/passwd.1.html
- /etc/login.defs documentation and examples:
/etc/login.defson your system or distribution docs