← 返回命令列表

Linux command

chage 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Example

chage -l username

Example

sudo chage -M 10 username

Disable

sudo chage -M -1 username

Example

sudo chage -E 2025-12-31 username

Example

sudo chage -d 0 username

Re-enable

sudo chage -E -1 username

说明

chage changes user password expiry information stored in /etc/shadow. It controls the number of days between required password changes, the date of the last password change, and account expiration dates. System administrators use chage to enforce password policies, such as requiring users to change passwords at regular intervals, setting grace periods after expiration, and disabling accounts on a specific date. The -l option allows any user to view their own aging information without root privileges. Setting the last password change date to 0 with -d forces an immediate password change on the user's next login, which is commonly used when creating new accounts or after a security incident.

参数

-d, --lastday LAST_DAY
Set the date of last password change (YYYY-MM-DD or days since epoch)
-E, --expiredate EXPIRE_DATE
Set account expiration date; use -1 to remove expiration
-i, --iso8601
Output dates in ISO 8601 format
-I, --inactive DAYS
Days of inactivity after password expiration before account lockout
-l, --list
Display account aging information
-m, --mindays MIN_DAYS
Minimum days between password changes
-M, --maxdays MAX_DAYS
Maximum days before password change required
-W, --warndays WARN_DAYS
Days before expiration to warn user

FAQ

What is the chage command used for?

chage changes user password expiry information stored in /etc/shadow. It controls the number of days between required password changes, the date of the last password change, and account expiration dates. System administrators use chage to enforce password policies, such as requiring users to change passwords at regular intervals, setting grace periods after expiration, and disabling accounts on a specific date. The -l option allows any user to view their own aging information without root privileges. Setting the last password change date to 0 with -d forces an immediate password change on the user's next login, which is commonly used when creating new accounts or after a security incident.

How do I run a basic chage example?

Run `chage -l username` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -d, --lastday LAST_DAY do in chage?

Set the date of last password change (YYYY-MM-DD or days since epoch)