Understanding /etc/shadow file format on Linux

Understanding /etc/shadow file format on Linux

The /etc/shadow file is a system configuration file on Unix-like operating systems, including Linux and macOS, that stores encrypted passwords for the users on the system. It is used in conjunction with the /etc/passwd file, which stores basic information about the users, such as their names and user IDs.

The /etc/shadow file is a plain text file that consists of a series of lines, each representing a user on the system. Each line in the file has the following format:

r‮efe‬r to:lautturi.com
username:password:last_password_change:minimum_password_age:maximum_password_age:password_warning_period:password_inactive_period:account_expiration_date

The fields are separated by colons (:) and have the following meanings:

  • username: The name of the user.
  • password: An encrypted password that is used to authenticate the user.
  • last_password_change: The date when the user's password was last changed, in the format YYYY-MM-DD.
  • minimum_password_age: The minimum number of days that must pass before the user is allowed to change their password again.
  • maximum_password_age: The maximum number of days that a password is valid before it expires and the user is required to change it.
  • password_warning_period: The number of days before a password is set to expire that the user is warned to change it.
  • password_inactive_period: The number of days after a password has expired that the user's account is locked and cannot be used.
  • account_expiration_date: The date when the user's account is set to expire, in the format YYYY-MM-DD.

For example, a line in the /etc/shadow file might look like this:

alice:$lzwq3lk.....
Created Time:2017-10-30 14:27:29  Author:lautturi