• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

chpasswd : command not found

by Deepika

The chpasswd command is a utility in Linux that is used to change the passwords of multiple users at once. It reads a list of user names and password hashes from standard input and updates the password for each user in the system password file (usually /etc/passwd).

To use the chpasswd command, you will need to provide a list of user names and password hashes in the following format:

username:password_hash

Where username is the user name of the user whose password you want to change, and password_hash is the password hash for the new password.

Here is an example of using the chpasswd command to change the password for the user john to password123:

# echo "john:$6$salt$password123" | chpasswd

In this example, $6$salt$ is the salt for the password hash (which is used to increase the security of the password), and password123 is the plaintext password. The echo command is used to print the user name and password hash to standard output, which is then piped to the chpasswd command.

If you encounter the below error while running the command chpasswd:

chpasswd : command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
Debian apt-get install passwd
Ubuntu apt-get install passwd
Alpine apk add shadow
Arch Linux pacman -S shadow
Kali Linux apt-get install passwd
Fedora dnf install shadow-utils-2
Raspbian apt-get install passwd

chpasswd Command Examples

1.Change the password for a specific user:

# printf "username:new_password" | sudo chpasswd

2.Change the passwords for multiple users (The input text must not contain any spaces.):

# printf "username_1:new_password_1\nusername_2:new_password_2" | sudo chpasswd

3.Change the password for a specific user, and specify it in encrypted form:

# printf "username:new_encrypted_password" | sudo chpasswd --encrypted

4.Change the password for a specific user, and use a specific encryption for the stored password:

# printf "username:new_password" | sudo chpasswd --crypt-method NONE|DES|MD5|SHA256|SHA512

Filed Under: Linux

Some more articles you might also be interested in …

  1. “iscsiadm” Discovery TimeOut With Two Or More Network Interfaces in CentOS/RHEL
  2. How to create a networking bridge under CentOS/RHEL
  3. einfo Command Examples in Linux
  4. How to Disable/Enable Numa for Virtual Machine (XEN based)
  5. CentOS / RHEL 7 : Understanding Kexec and Kdump
  6. RHEL 7 – RHCSA Notes (Cheat Sheets)
  7. How to Remove/ Disable Bash shell Command History on Linux
  8. When to use rescan-scsi-bus.sh -i (LIP flag) in CentOS/RHEL
  9. vgcreate Command Examples in Linux
  10. colorpicker: A minimalist X11 colorpicker

You May Also Like

Primary Sidebar

Recent Posts

  • glab Command Examples
  • “glab repo” Command Examples
  • “glab release” Command Examples
  • “glab pipeline” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright