How to use chage Command In Linux
chage is a command-line tool that is used to update the user account aging information. We can use the `chage` command to expire the password of an account. `chage` command provides `-d` or `–lastday` option, with this option mentioning the number of number days after January 1st, 1970 password should expire. So, to expire the password now we can use the 0 option. When we use 0 this means that the password expired on January 1st, 1970, and it must be changed.
chage --lastday 0 username
We can verify the password is expired or not by using the change command with the `-l` option.
On the next login, the system will ask the user to reset the password.
Additional Considerations
- It is important to ensure that you have administrative privileges (root or sudo access) to execute the necessary commands.
- Make sure to replace “username” with the actual username of the user whose password you want to expire.
- The chage command provides additional options to manage user account aging, such as setting maximum and minimum password ages. Refer to the command’s documentation (man chage) for more details.
How to Force User to Change Password at Next Login in Linux
For security reasons, you must frequently change the password of accounts on the system. In this article, we are going to see how we can force the user to change the password on the next login in Linux. We can do that by two methods, one is using `passwd` command and the other is by using the `chage` command.