Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
A normal user runs passwd to change the own password (the old one is asked first). root can set the password of any user without knowing the old one, and can lock, unlock, delete or expire passwords.
The password is stored as a hash in /etc/shadow. PAM checks the quality of a new password (length, dictionary words) with the rules in /etc/security/pwquality.conf; root gets only a warning.
passwd also has short options for password aging (-x, -n, -w, -i); chage has the same and more.
Zo schrijf je het
passwd [OPTION]... [LOGIN]Opties 17
Meest gebruikt
Set and change
Lock and status
Aging
Other
Niets past bij dit filter.
Voorbeelden 12
$ als gewone gebruiker# als root (of met sudo)
1Change your own password
passwd Current password: New password: Retype new password:The new password must pass the quality check.
2Set the password of another user
passwd lisaroot does not need the old password.
3Set a password from a script
echo 'S3cure#Pass' | passwd --stdin lisaFast for labs. In real scripts the password can end up in the shell history — use
chpasswdfrom a protected file.4Show the password status
passwd -S lisa lisa P 2026-10-25 0 90 7 -1P = usable password, L = locked, NP = no password. Then last change, min, max, warn, inactive.
5Lock and unlock
passwd -l lisa passwd -u lisaA lock blocks password logins only, not SSH keys.
6Force a new password at the next login
passwd -e lisaUse it after you set a first password for a new person.
7Set password aging
passwd -x 90 -n 1 -w 7 lisaSame as
chage -M 90 -m 1 -W 7 lisa.8Check all accounts for weak states (security)
passwd -Sa | awk '$2 == "NP"'Accounts without a password are a big risk.
9Set many passwords at once
chpasswd < /root/new-passwords.txtFile lines are
user:password. Remove the file afterwards.10Test the quality rules
grep -E '^(minlen|minclass|dictcheck)' /etc/security/pwquality.confSet
minlen = 12to ask for longer passwords.11Reset the root password from a rescue shell
passwd rootIn the rescue mode (rd.break or init=/bin/bash), see the boot chapter; then
touch /.autorelabel.12Delete a password (do not use on servers)
passwd -d testuserThe account then has an empty password — only for special kiosk tests.
Niets past bij dit filter.
Let op
passwd -ldoes not stop SSH key logins. Useusermod -e 1orchage -E 0to block the account.- On RHEL 9 and older, passwd came from its own package with other long names (
--maximum,--minimum); the short options are the same.
Bestanden
/etc/shadow- The password hashes and aging data.
/etc/security/pwquality.conf- Password quality rules.
/etc/pam.d/passwd- PAM rules for passwd.
Exitcodes
0 | Done. |
1 | Permission denied. |
2 | Wrong option. |
3 | Unexpected failure, nothing done. |
4 | The password file is missing. |
5 | The password file is busy, try again. |
6 | Wrong argument. |