passwd: command not found

The passwd command is used by root to set or reset a password for any user. A user can use the passwd command themselves to reset their own password. It is also used to set the initial password for a user after creating the account with the useradd command.

Note: The screen will not show any output when a user is setting a password. Some users will mistake this for a problem, but it is actually Linux hiding the number of characters being used in the password.

The syntax of the passwd command is:

$ passwd [user name]

where [user name] can be used by root to set a specific user’s password.

The root user can set the password for any user to any value without knowing his current password. As a regular user, simply type the command at the CLI. You’ll see something like this in response:

$ passwd
Changing password for geek.
Old Password:

Once you’ve entered the old password, you’re asked for the new one, and then asked to repeat it. If you enter the same new password twice, it’s changed. It looks like this. Note that the actual passwords you’ve typed do not show up on the screen.

New password:
Re-enter new password:
Password changed.

If you encounter below error while running the passwd command:

passwd: command not found

you may try installing the passwd package as shown below as per your choice of distribution.

Distribution Command
Debian apt-get install passwd
Ubuntu apt-get install passwd
Arch Linux pacman -S passwd
Kali Linux apt-get install passwd
CentOS yum install passwd
Fedora dnf install passwd
Raspbian apt-get install passwd

passwd command examples

1. To lock the user account:

# passwd -l geek

2. To unlock the user account:

# passwd -u geek

3. To delete the password for the user account:

# passwd -d geek

4. To expire the password for the user account:

# passwd -e geek

5. To set the min / max password life

# passwd -n 10 geek
# passwd -x 100 geek

6. To set warning message time:

# passwd -w 2 geek

7. To set the user account inactivity time:

# passwd -i 20 geek

8. To get the short info about user account passwd:

# passwd -S geek
Related Post