Manpages

名 称

passwd - 更 改 用 户 密 码

大 纲

passwd [选 项 ] [登 录 ]

描 述

The passwd command changes passwords for user accounts. A normal user may only change the password for their own account, while the superuser may change the password for any account. passwd also changes the account or associated password validity period. 密 码 更 改 如 果 有 旧 密 码 , 首 先 提 示 用 户 输 入 旧 密 码 。 加 密 这 个 密 码 然 后 和 存 储 的 密 码 进 行 比 较 。 用 户 只 有 一 次 机 会 输 入 正 确 密 码 。 允 许 超 级 用 户 略 过 这 个 步 骤 , 以 便 更 改 忘 记 了 的 密 码 。

After the password has been entered, password aging information is checked to see if the user is permitted to change the password at this time. If not, passwd refuses to change the password and exits. 提 示 用 户 输 入 两 次 新 密 码 。 第 二 次 和 第 一 次 进 行 比 较 , 并 且 需 要 相 同 才 能 更 改 密 码 。 然 后 , 测 试 密 码 的 负 责 程 度 。 一 般 来 讲 , 密 码 应 该 包 含 6 到 8 位 字 符 , 从 下 边 的 一 个 或 多 个 集 合 中 选 择 :

• 小 写 字 母

• 数 字 0 到 9

• 标 点 符 号

Care must be taken not to include the system default erase or kill characters. passwd will reject any password which is not suitably complex. 关 于 用 户 密 码 的 提 示
The security of a password depends upon the strength of the encryption algorithm and the size of the key space. The legacy UNIX System encryption method is based on the NBS DES algorithm. More recent methods are now recommended (see ENCRYPT_METHOD). The size of the key space depends upon the randomness of the password which is selected. 由 于 粗 心 地 或 处 理 选 择 密 码 , 会 危 及 密 码 的 安 全 。 由 于 这 个 原 因 , 您 不 应 该 选 择 出 现 在 词 典 中 或 者 必 须 要 写 下 来 才 能 记 住 的 密 码 。 密 码 也 不 应 该 是 一 个 名 字 、 许 可 证 号 、 生 日 或 者 街 道 号 。 所 有 这 些 可 以 用 于 猜 测 来 损 害 系 统 安 全 。

You can find advice on how to choose a strong password on http://en.wikipedia.org/wiki/Password_strength

选 项

The options which apply to the passwd command are:

-a, --all

This option can be used only with -S and causes show status for all users.

-d, --delete 删 除 用 户 密 码 (让 它 为 空 )。 这 是 禁 用 一 个 用 户 密 码 的 快 速 方 法 。 它 将 设 置 给 出 名 称 的 账 户 。

-e, --expire 让 一 个 账 户 的 密 码 立 即 过 期 。 这 可 以 强 制 一 个 用 户 下 次 登 录 时 更 改 密 码 。

-h, --help 显 示 帮 助 信 息 并 退 出 。

-i, --inactive INACTIVE

This option is used to disable an account after the password has been expired for a number of days. After a user account has had an expired password for INACTIVE days, the user may no longer sign on to the account.

-k, --keep-tokens 表 示 密 码 更 改 只 应 该 因 为 认 证 口 令 (密 码 )过 期 更 改 。 用 户 希 望 保 持 他 们 尚 未 过 期 的 口 令 。

-l, --lock 锁 定 指 定 账 户 的 密 码 。 此 选 项 通 过 将 密 码 更 改 为 一 个 不 可 能 与 加 密 值 匹 配 的 值 来 禁 用 (它 在 密 码 开 头 添 加 一 个 “!”)。

Note that this does not disable the account. The user may still be able to login using another authentication token (e.g. an SSH key). To disable the account, administrators should use usermod --expiredate 1 (this set the account's expire date to Jan 2, 1970). 被 锁 定 了 密 码 的 用 户 不 允 许 更 改 密 码 。

-n, --mindays MIN_DAYS

Set the minimum number of days between password changes to MIN_DAYS. A value of zero for this field indicates that the user may change their password at any time.

-q, --quiet 安 静 模 式 。

-r, --repository REPOSITORY

change password in REPOSITORY repository

-R, --root CHROOT_DIR

Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory. Only absolute paths are supported.

-S, --status 显 示 账 户 状 态 信 息 。 状 态 信 息 包 含 7 个 字 段 。 首 个 字 段 是 用 户 的 登 录 名 , 第 二 个 字 段 表 示 用 户 账 户 是 否 已 经 锁 定 密 码 (L)、 没 有 密 码 (NP)或 者 密 码 可 用 (P), 第 三 个 字 段 给 出 最 后 一 次 更 改 密 码 的 日 期 。 接 下 来 的 四 个 字 段 分 别 是 密 码 的 最 小 年 龄 、 最 大 年 龄 、 警 告 期 和 禁 用 期 。 这 些 年 龄 以 天 为 单 位 计 算 。

-u, --unlock

Unlock the password of the named account. This option re-enables a password by changing the password back to its previous value (to the value before using the -l option).

-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 that their password is about to expire.

-x, --maxdays MAX_DAYS

Set the maximum number of days a password remains valid. After MAX_DAYS, the password is required to be changed.

Passing the number -1 as MAX_DAYS will remove checking a password's validity.

CAVEATS

密 码 复 杂 性 检 查 在 每 台 机 器 间 不 同 。 用 户 应 该 选 择 适 合 的 尽 量 复 杂 的 密 码 。 在 启 动 了 NIS 的 系 统 上 , 如 果 没 有 登 录 NIS 服 务 器 , 用 户 或 许 不 能 更 改 自 己 的 密 码 。

passwd uses PAM to authenticate users and to change their passwords.

文 件

/etc/passwd 用 户 账 户 信 息 。

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

/etc/pam.d/passwd

PAM configuration for passwd.

退 出 值

The passwd command exits with the following values:

0

success

1

permission denied

2

invalid combination of options

3

unexpected failure, nothing done

4

unexpected failure, passwd file missing

5

passwd file busy, try again

6

invalid argument to option

参 见

chpasswd(8), passwd(5), shadow(5), usermod(8).