← 返回命令列表

Linux command

passwd 命令

文本

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

常用示例

Change your password

passwd

Change another user's password

passwd [username]

Lock a user account

passwd -l [username]

Unlock a user account

passwd -u [username]

Force password change

passwd -e [username]

Set password to expire

passwd -x [90] [username]

Show password status

passwd -S [username]

Delete user's password

passwd -d [username]

说明

passwd changes user passwords. When run without arguments by a regular user, it prompts for the current password and then allows setting a new one. Root can change any user's password without knowing the old one. The tool enforces password policies including minimum length, complexity requirements, and history restrictions. These policies are configured in /etc/login.defs and PAM configuration. passwd also manages password aging, allowing administrators to force periodic password changes, expire passwords, and lock/unlock accounts.

参数

-l, --lock
Lock the account password.
-u, --unlock
Unlock the account password.
-d, --delete
Delete password (make passwordless).
-e, --expire
Force password change on next login.
-n _days_, --mindays _days_
Minimum days between changes.
-x _days_, --maxdays _days_
Maximum days before change required.
-w _days_, --warndays _days_
Days before expiry to warn user.
-i _days_, --inactive _days_
Days after expiry before account disabled.
-S, --status
Show password status information.
-a, --all
With -S, show status for all users.
--stdin
Read password from stdin (non-interactive).

FAQ

What is the passwd command used for?

passwd changes user passwords. When run without arguments by a regular user, it prompts for the current password and then allows setting a new one. Root can change any user's password without knowing the old one. The tool enforces password policies including minimum length, complexity requirements, and history restrictions. These policies are configured in /etc/login.defs and PAM configuration. passwd also manages password aging, allowing administrators to force periodic password changes, expire passwords, and lock/unlock accounts.

How do I run a basic passwd example?

Run `passwd` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -l, --lock do in passwd?

Lock the account password.