linux chage_chage命令教程,以及在Linux中管理用户帐户的示例

linux chage_chage命令教程,以及在Linux中管理用户帐户的示例_第1张图片

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系统中更改用户密码有效期信息的工具和命令。 使用此命令,我们可以设置密码更改时间,锁定状态,用户帐户的活动或不活动。

句法 (Syntax)

We will use following syntax for chage command.

我们将对chage命令使用以下语法。

chage [options] LOGIN

帮帮我 (Help)

$ chage -h
linux chage_chage命令教程,以及在Linux中管理用户帐户的示例_第2张图片 Help 帮帮我

显示用户的密码和相关信息(Show Password And Related Information For A User)

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
Show Password And Related Information For A User Show Password And Related Information For A User 显示用户的密码和相关信息
  • 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将显示密码过期前的警告天数

设置用户的密码到期日期(Set Password Expiry Date For A User)

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
linux chage_chage命令教程,以及在Linux中管理用户帐户的示例_第3张图片 Set Password Expiry Date For A User 设置用户的密码到期日期

设置密码过期警告消息(Set Password Expiry Warning Message)

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
linux chage_chage命令教程,以及在Linux中管理用户帐户的示例_第4张图片 Set Password Expiry Warning Message 设置密码过期警告消息

设置帐户有效期(Set Account Expiry Date)

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
linux chage_chage命令教程,以及在Linux中管理用户帐户的示例_第5张图片 Set Account Expiry Date 设置帐户有效期

为用户的活动设置锁定时间(Set Lock Period For In Activity of User)

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
linux chage_chage命令教程,以及在Linux中管理用户帐户的示例_第6张图片 Set Lock Period For In Activity of User 为用户的活动设置锁定时间

禁用用户的密码时效(Disable Password Aging For User)

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
linux chage_chage命令教程,以及在Linux中管理用户帐户的示例_第7张图片 Disable Password Aging For User 禁用用户的密码时效
LEARN MORE  How To Allow Normal User Run Commands As Root In Linux with sudo Command?
了解更多信息如何使用sudo命令在Linux中以root用户身份允许普通用户运行命令?

翻译自: https://www.poftut.com/chage-command-tutorial-examples-manage-user-accounts-linux/

linux chage

你可能感兴趣的:(linux,python,java,git,shell)