LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

chpasswd

batch update user passwords

TLDR

Change the password for a specific user
$ printf "[username]:[new_password]" | sudo chpasswd
copy
Change passwords for multiple users
$ printf "[username_1]:[password_1]\n[username_2]:[password_2]" | sudo chpasswd
copy
Change password using an encrypted form
$ printf "[username]:[encrypted_password]" | sudo chpasswd -e
copy
Change password with specific encryption method
$ printf "[username]:[new_password]" | sudo chpasswd -c [SHA512]
copy

SYNOPSIS

chpasswd [options]

DESCRIPTION

chpasswd reads username:password pairs from standard input and updates user passwords in batch. This is useful for system administration tasks requiring password changes for multiple users at once, such as during initial account provisioning or automated password rotation.Input format is one user per line as username:password with no spaces around the colon. Passwords are encrypted using the system default method (typically SHA-512) unless a different method is specified. Pre-encrypted passwords can also be supplied with the -e flag.

PARAMETERS

-e, --encrypted

Passwords are supplied in encrypted form
-c, --crypt-method method
Specify encryption method (NONE, DES, MD5, SHA256, SHA512)
-m, --md5
Use MD5 encryption
-s, --sha-rounds rounds
Number of rounds for SHA encryption

CONFIGURATION

/etc/login.defs

Controls default encryption method (ENCRYPTMETHOD), SHA rounds (SHACRYPTMINROUNDS, SHACRYPTMAX_ROUNDS), and other password policy settings used by chpasswd.

INSTALL

sudo apt install passwd
copy
sudo pacman -S shadow
copy
sudo apk add shadow
copy
sudo zypper install shadow
copy
nix profile install nixpkgs#shadow
copy

CAVEATS

Requires root privileges. Passwords passed via command line may be visible in process listings. Consider using encrypted passwords or secure input methods in scripts. DES encryption is considered weak.

HISTORY

chpasswd is part of the shadow-utils package for batch password management.

SEE ALSO

passwd(1), usermod(8), useradd(8)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid