To set accounts to be disabled after password expiration on CentOS or Red Hat Enterprise Linux (RHEL), you can use the chage
command.
chage
command with the -M
option to specify the number of days after which the password will expire. For example, to set an account to be disabled after 90 days of password expiration, you can use the following command:sudo chage -M 90 username
Replace username
with the actual username of the account that you want to set.
chage
command with the -I
option to specify the number of days of inactivity after which the account will be disabled. For example, to set an account to be disabled after 60 days of inactivity, you can use the following command:sudo chage -I 60 username
Replace username
with the actual username of the account that you want to set.
-M
and -I
options together. For example:sudo chage -M 90 -I 60 username
This will set the account to be disabled after 90 days of password expiration or 60 days of inactivity, whichever occurs first.
Note: The
chage
command only works for local accounts, not for accounts that are managed by external authentication systems such as LDAP or Kerberos. To set password expiration and inactivity limits for these types of accounts, you will need to use the tools provided by the authentication system.