CHAGE(1)

名称
chage - 更改用户密码过期信息

大纲

chage [选项] 登录

描述

The chage command changes the number of days between password changes and the date of the last password change. This information is used by the system to determine when a user must change their password.

选项

chage 命令可以接受的选项有：

-d, --lastday LAST_DAY
    Set the number of days since January 1st, 1970 when the password was last changed. The date may also be expressed in the format YYYY-MM-DD (or the format more commonly used in your area).

-E, --expiredate EXPIRE_DATE
    Set the date or number of days since January 1, 1970 on which the user's account will no longer be accessible. The date may also be expressed in the format YYYY-MM-DD (or the format more commonly used in your area). A user whose account is locked must contact the system administrator before being able to use the system again.

    EXPIRE_DATE 设置为 -1 会移除账户的过期日期。

-h, --help
    现实帮助信息并退出。

-I, --inactive INACTIVE
    Set the number of days of inactivity after a password has expired before the account is locked. The INACTIVE option is the number of days of inactivity. A user whose account is locked must contact the system administrator before being able to use the system again.

    INACTIVE 设置为 -1 会移除账户禁用功能。

-l, --list
    现实账户年龄信息。

-m, --mindays MIN_DAYS
    在密码更改之间的最小天数设置为 MIN_DAYS。此字段中的 0 值表示用户可以在任何时间更改其密码。

-M, --maxdays MAX_DAYS
    Set the maximum number of days during which a password is valid. When MAX_DAYS plus LAST_DAY is less than the current day, the user will be required to change their password before being able to use their account. This occurrence can be planned for in advance by use of the -W option, which provides the user with advance warning.

    MAX_DAYS 设置为 -1 会移除密码有效性检查。

-R, --root CHROOT_DIR
    Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.

-W, --warndays WARN_DAYS
    Set the number of days of warning before a password change is required. The WARN_DAYS option is the number of days prior to the password expiring that a user will be warned their password is about to expire.

如果没有选择任何选项，chage 会进入交互模式，以所有字段的当前值提示用户。输入一个新值可以更改这些字段，或者留空使用当前值。当前值出现在 [ ] 标记对里。

注意

chage 需要有一个影子密码文件才可用。

只有 root 才可以使用 chage，一个特殊情况是 -l 选项，用来让非特权用户觉得自己的密码或账户何时过期。

配置文件

在 /etc/login.defs 中有如下配置变量，可以用来更改此工具的行为：

文件

/etc/passwd
    用户账户信息。

/etc/shadow
    安全用户账户信息。

退出值

chage 命令有如下退出值：

0
    成功

1
    权限不够

2
    无效的命令语法

15
    无法找到影子密码文件

参见

passwd(5), shadow(5).