We can limit the number of days between two password changes for a user in Ubuntu. One of the reasons for doing that could be a security issue. Ideally, a user should be allowed to change password any at point in time. But, sometimes circumstances warrant specific solutions. So, in this article, we chose to cover how to set minimum number of days between password changes in Ubuntu.
What we are trying to achieve here is that, a user has to wait for ‘n’ number of days from last password change day before he/she is allowed to change his/her password.
The two command-line utilities through which it can be done are –
- chage and,
- passwd.
Note: Following operations require superuser privileges. In case you don’t have the privileges then, contact your System Administrator for assistance.
Set minimum number of days between password changes in Ubuntu
We start with chage –
I. Use the following syntax to set minimum number of days –
sudo chage -m <minimum_days> <username>
where, -m option is used to set minimum number of days.
So, for a user – abc, we want the user to wait for 7 days from last password change day before he/she can change the password then –
sudo chage -m 7 abc
Now, what if we set the wait days as 0 (zero). In that case, the user can change password at any time –
sudo chage -m 0 abc
II. Similar outcome can also be achieved through passwd command-line utility –
sudo passwd -n <minimum_days> <username>
Continuing with the above example of user – abc and minimum days – 7
sudo passwd -n 7 abc
Here also, a zero in minimum days tells us that a user is allowed to change his/her password at any point in time.
In conclusion, we have covered how to make the user wait for ‘n’ number of days before he/she can make changes to his/her password.
Additional Info –
We can view changes we just made using chage command-line utility itself.
sudo chage -l <username>
And, look for field which shows us the minimum number of days between password change.