Passwords, ageing and locked accounts
Account expiry and password ageing are two different things stored in two different fields, and passwd -S reports a state that does not mean what it looks like. This guide reads the shadow fields directly, sets a policy with chage, and shows why locking an account that never had a password does not do what you expect.
Users and Groups Guide 20 of 38 Intermediate
- PlatformsUbuntu 26.04 LTS + AlmaLinux 10.2
- LVM2.03.31 (Ubuntu) / 2.03.36 (AlmaLinux)
- nftables1.1.6 (Ubuntu) / 1.1.5 (AlmaLinux)
- TimeAbout 16 min
shadow-utils, identical on both families. The default PASS_MAX_DAYS of 99999 means 'never' in practice and is the default on both.
- Firewallufw 0.36.2 enabled but reporting inactive / firewalld active
- Network confignetplan + systemd-networkd / NetworkManager 1.56.0
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| LFCS-A01 | 192.168.0.70 | Ubuntu 26.04 LTS | Primary host - most guides run only here | 2 Core | 4 GB | 50 GB |
| LFCS-C01 | 192.168.0.72 | AlmaLinux 10.2 | The other distribution - dnf, firewalld and NetworkManager | 2 Core | 4 GB | 50 GB |
This guide includes
Use this because account expiry and password ageing are two different things kept in two different files. This matters because locking a password that does not exist behaves differently from locking one that does.
- reading the ageing fields, including the date that is a number
- setting a policy with chage
- forcing a password change at the next login
- locking and unlocking an account, with and without a password set
- confirming that ageing behaves identically on Ubuntu
Before you start
- guide 19 - the shadow file.
-
The ageing fields, and a date that is a number
-
Setting a policy
-
Forcing a change at the next login
-
Locking a password that does not exist
-
And locking one that does
-
The same commands on Ubuntu