CHPASSWD(8)

๐Ÿ’– CHPASSWD โ€” the batch password glow-up ๐Ÿ’–

okay bestie, so this is chpasswd from the System Management Commands section (that's section 8, for the admins ๐Ÿซถ). it's the tool you call when you need to update a whole group of existing users' passwords in one go, no cap.


โœจ SYNOPSIS โœจ

chpasswd [options]

๐ŸŒธ DESCRIPTION ๐ŸŒธ

so here's the vibe: chpasswd reads a list of user name + password pairs from standard input, and uses that tea โ˜• to update a bunch of existing users at once. every single line has to look like this:

user_name:password

by default, the passwords you feed it have to be in clear-text, and chpasswd does the encrypting for you. also, the password age gets updated too, if it's present. periodt.

by default, passwords get encrypted by PAM, but โ€” and listen, this is not recommended โ€” you can pick a different encryption method with the -e or -c options.

here's the important part tho ๐Ÿ‘€ โ€” except when PAM is doing the encrypting, chpasswd first updates all the passwords in memory, and then commits all the changes to disk only if no errors happened for any user. all or nothing, iconic behavior fr fr.

but when PAM is the one encrypting the passwords (and updating them in the system database), then if a password can't be updated, chpasswd just keeps going and updates the next users, and it'll return an error code on exit. messy but functional ๐Ÿ’€

this command is made for big system environments where you're creating a ton of accounts all at once. it's giving "I have 4,000 interns and one afternoon" energy.


๐Ÿ’… OPTIONS ๐Ÿ’…

the options that apply to the chpasswd command are:

  • -c, --crypt-method METHOD โ€” use the method you specify to encrypt the passwords.

the available methods are SHA256, SHA512, YESCRYPT and NONE, if your libc supports them.

by default, PAM is used to encrypt the passwords.

  • -e, --encrypted โ€” the passwords you supplied are already in encrypted form.
  • -h, --help โ€” show the help message and dip out.
  • -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. no SELINUX support.
  • -P, --prefix PREFIX_DIR โ€” apply changes to configuration files under the root filesystem found under the directory PREFIX_DIR. this option does not chroot, and it's meant for preparing a cross-compilation target. some limitations, bestie, listen up: NIS and LDAP users/groups are not verified. PAM authentication is using the host files. No SELINUX support.
  • -s, --sha-rounds ROUNDS โ€” use the specified number of rounds to encrypt the passwords.

you can only use this option with crypt method: SHA256 SHA512 YESCRYPT

by default, the number of rounds for SHA256 or SHA512 is defined by the SHA_CRYPT_MIN_ROUNDS and SHA_CRYPT_MAX_ROUNDS variables in /etc/login.defs.

a minimal value of 1000 and a maximal value of 999,999,999 will be enforced for SHA256 and SHA512. the default number of rounds is 5000.

by default, the number of rounds for YESCRYPT is defined by the YESCRYPT_COST_FACTOR in /etc/login.defs.

a minimal value of 1 and a maximal value of 11 will be enforced for YESCRYPT. the default number of rounds is 5.


๐Ÿšจ CAVEATS ๐Ÿšจ

remember to set permissions or umask so that other users can't read your unencrypted files. please please please, bestie, do not leave your plaintext passwords just vibing out in the open where anybody can read them ๐Ÿ˜ญ lock it down.


๐ŸŽ€ CONFIGURATION ๐ŸŽ€

these configuration variables in /etc/login.defs change how this tool behaves:

SHA_CRYPT_MIN_ROUNDS (number), SHA_CRYPT_MAX_ROUNDS (number)

when ENCRYPT_METHOD is set to SHA256 or SHA512, this defines the number of SHA rounds the encryption algorithm uses by default โ€” like, when the number of rounds isn't specified on the command line.

with a lot of rounds, it's harder to brute force the password. but also note that more CPU resources will be needed to authenticate users. tradeoffs, we love them ๐Ÿ’…

if it's not specified, the libc will choose the default number of rounds (5000), which is orders of magnitude too low for modern hardware. yeah. yikes.

the values must be inside the 1000-999,999,999 range.

if only one of the SHA_CRYPT_MIN_ROUNDS or SHA_CRYPT_MAX_ROUNDS values is set, then that value will be used.

if SHA_CRYPT_MIN_ROUNDS > SHA_CRYPT_MAX_ROUNDS, the highest value will be used.

note: this only affects the generation of group passwords. the generation of user passwords is done by PAM and is subject to the PAM configuration. it's recommended to set this variable consistently with the PAM configuration.

YESCRYPT_COST_FACTOR (number)

when ENCRYPT_METHOD is set to YESCRYPT, this defines the cost factor the encryption algorithm uses by default โ€” when the cost factor isn't specified on the command line, that is.

with a high cost factor, it's harder to brute force the password. but also note that more CPU resources will be needed to authenticate users. same energy as above โœจ

the value must be inside the 1-11 range.

note: this only affects the generation of group passwords. the generation of user passwords is done by PAM and is subject to the PAM configuration. it's recommended to set this variable consistently with the PAM configuration.

๐Ÿ“ FILES ๐Ÿ“

  • /etc/passwd โ€” user account information.
  • /etc/shadow โ€” secure user account information.
  • /etc/login.defs โ€” shadow password suite configuration.
  • /etc/pam.d/chpasswd โ€” PAM configuration for chpasswd.

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

passwd(1), newusers(8), login.defs(5), useradd(8).


and that's the whole page, bestie ๐Ÿฆ‹ go forth and batch-update responsibly. this little masterpiece is from shadow-utils 4.20.0, dated 07/30/2026. slay, stay encrypted, and never ever leave plaintext passwords lying around ๐Ÿ’–โœจ๐Ÿ‘‘

๐Ÿ“ฆ where this page comes from