linux chage
chage
is a tool and command used to change user password expiry information in Linux, BSD, Unix systems. With this command we can set password change time, lock status, activity or inactivity of the user account.
chage
是用于在Linux,BSD,Unix系统中更改用户密码有效期信息的工具和命令。 使用此命令,我们可以设置密码更改时间,锁定状态,用户帐户的活动或不活动。
We will use following syntax for chage
command.
我们将对chage
命令使用以下语法。
chage [options] LOGIN
$ chage -h
We may want to get detailed password and related information about the user account. This will not list the password of user account. We will use -l
or --list
options. In this example we will look user account name ismail
我们可能想要获取有关用户帐户的详细密码和相关信息。 这不会列出用户帐户的密码。 我们将使用-l
或--list
选项。 在此示例中,我们将查找用户帐户名ismail
$ chage -l ismail
Last password change
will show when the password is changed last time
Last password change
将显示Last password change
密码
Password expires
shows when will password expire
Password expires
显示密码何时过期
Password inactive
shows when will be password inactive
Password inactive
显示Password inactive
何时无效
Account expires
shows when will account will expire
Account expires
显示帐户何时过期
Minimum number of days between password change
shows how many day the password will change
Minimum number of days between password change
显示密码将更改多少天
Maximum number of days between password change
shows how many day the password will change
Maximum number of days between password change
显示密码将更改多少天
Number of days of warning before password expire
show how much day before the password expire warning will be shown
Number of days of warning before password expire
将显示密码过期前的警告天数
In order to set user account password expire date we need to have root privileges. We will use -M
option to specify number of days to password expire. In this example we will set password expiry date for user ismail
to 10
days.
为了设置用户帐户密码的过期日期,我们需要具有root特权。 我们将使用-M
选项指定密码过期的天数。 在此示例中,我们将用户ismail
密码到期日期设置为10
天。
$ chage -M 10 ismail
Before the user accounts password expires some warning messages are shown to the user. The time the warning message will be shown is by default 7 days. We can set this warning start days with -W
option. In this example we will start showing message before 10 days of password expire for user account ismail
在用户帐户密码过期之前,会向用户显示一些警告消息。 默认情况下,警告消息的显示时间为7天。 我们可以使用-W
选项设置警告开始日期。 在此示例中,我们将在用户帐户ismail
的密码过期10天之前开始显示消息
$ chage -W 10 ismail
Another useful feature of chage
is expiring a user account. Expiring user account will lock the account and can not connect remotely. We will use -E
option with a date. This date is in YYYY-MM-DD
format. In this example we will set account expire date for user ismail
at 2017-05-05
.
chage
另一个有用功能是使用户帐户过期。 用户帐户过期将锁定该帐户,并且无法远程连接。 我们将-E
选项与日期一起使用。 此日期为YYYY-MM-DD
格式。 在此示例中,我们将为用户ismail
设置帐户到期日期为2017-05-05
。
$ chsudoage -E 2017-05-05 ismail
Normally after password is expired the user is forced to change password. What is the user is not trying to change or not login to the system. This shows us an inactivity where user is not active. We can set some security measure if the user is not change his password in specified days. After the period is expired the user account is locked and only root can activate this account. We will use -I
option with number of days for inactivity.
通常,密码过期后,用户将被迫更改密码。 用户未尝试更改或未登录系统的原因是什么。 这向我们显示了用户不活跃的不活跃状态。 如果用户在指定日期内未更改其密码,我们可以设置一些安全措施。 期限到期后,用户帐户被锁定,只有root用户可以激活该帐户。 我们将使用-I
选项加上不活动的天数。
$ chsudoage -I 20 ismail
Some times we do not need any security measure. We only want to run account without any lock, password expiry etc. In this situations we can use previously examined options to disable them. This will reset all user account related security measures to the default.
有时我们不需要任何安全措施。 我们只想运行没有任何锁,密码到期等的帐户。在这种情况下,我们可以使用先前检查的选项来禁用它们。 这会将所有与用户帐户相关的安全措施重置为默认值。
$ chsudoage -m 0 -M 99999 -I -1 -E -1 ismail
翻译自: https://www.poftut.com/chage-command-tutorial-examples-manage-user-accounts-linux/
linux chage