Note: This is an RHCSA 7 exam objective.
To assign a password to a user account (here user), type:
# passwd user
To set an expiration date to a local user account (here user), type:
# chage -E YYYY-MM-DD user
To check the result, type:
# chage -l user
“chage -d 0 username” requires the user to change his password immediately after logon, which is a quite a nice feature.
It’s interesting. Thanks.
Is there an actual difference between using passwd -x 0 username and chage -E YYYY-MM-DD user?
Also, in case it helps anyone, you can use date -d ’90 days’ for example, if you need to find the exact date 90 days from now to use with something like chage.
I have to say that I didn’t know the passwd -x command. With this command and according to the man page, you can set the maximum password lifetime in days, when you specify a date or a number of days since January 1, 1970 with the chage -E command. In one case, it is a number of days from now, in the other case, a date in the future. At the end, you should get the same result.
echo Y0uRp@$$w0rD | passwd –stdin useraccount
Seems useful for scripting.