The chage command changes the number of days between password changes and the date of the last password change.
This information is used by the system to determine when a user must change their password.
The /etc/login.defs file defines the site-specific configuration for the shadow password suite including password aging configuration.
sudo chage -M 60 -m 7 -W 7 userName
sudo chage -M 99999 userName
sudo chage -l userName
Finally, you can also edit the /etc/shadow file in the following fields:
{userName}:{password}:{lastpasswdchanged}:{Minimum_days}:{Maximum_days}:{Warn}:{Inactive}:{Expire}:
Where,
It is recommended to use the chage command instead of editing the /etc/shadow file by hand,