Skip to main content
Linux

Password Last Changed: What does 18645 Mean?

By October 13, 2021September 12th, 2022No Comments

password last changed date

The password last changed date in Linux can be gained from the /etc/shadow file in Linux. You will need to be root as this is a restricted file. The field you want to look at is field 3. The field list is shown below:

  1. User
  2. Password
  3. Last change
  4. Min password age
  5. Max password age
  6. Password warning days
  7. Password inactivity lock
  8. Account expiry

Looking at my account it is 182625. If this is the when the password was changed, then what does it mean?

$ sudo getent shadow vagrant
vagrant:$6$dfMH5jB9NKW6iv1Y$FRWG5J5KC29deKUbAx3tVbh5RMDpT30eJrBQVmQ/syTkRHwHaUqsL.cDT09p6QzhsE6HtSPwlMnpy1Y5BoNS20:18625:0:99999:7:::

The date is expressed as the number of days after Jan 01 1970 that the password was changed. Oh, well that is useful!! Not. Don’t get too stressed, we can see the password last changed date by using the chage command. I am logged in as vagrant so I don’t need to use sudo with the command. If you need to check the data for another account you will need to use the command sudo.

$ sudo getent shadow vagrant
vagrant:$6$dfMH5jB9NKW6iv1Y$FRWG5J5KC29deKUbAx3tVbh5RMDpT30eJrBQVmQ/syTkRHwHaUqsL.cDT09p6QzhsE6HtSPwlMnpy1Y5BoNS20:18625:0:99999:7:::
[vagrant@rhel8 ~]$ chage -l vagrant
Last password change : Dec 29, 2020
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7

OK, but can I calculate the password last changed  date myself? Well, yes, how good are you at counting? No really it is easy. The command date in Linux is flexible, we can use it to display the current date as well as offsets to it. We can also specify a date with the offset. So if we specify the date of January 1st 1970 and add days to it will will see the password last changed date we so look for.

$ date +%F --date 'Jan 01 1970'
1970-01-01
$ date +%F --date 'Jan 01 1970 18625 days'
2020-12-29

We first prove that we can print the date for 01 Jan 1970 and then add 18625 days to it. I said that was easy and I was not lying was I. The main thing is to get practice on your own systems and you will so learn Linux the way you want to, Linux is really powerful and by knowing the right commands and their options we can do most things quite easily.