How to Reset User Password in Linux/Unix-like OS?

Linux and UNIX-like operating systems provide the passwd command to reset or change the user password. The passwd command is used to change the passwords for user and group accounts. A normal user can change the password for his/her own account whereas the superuser (or root) can change the password for any other account. The passwd changes the user password by updating a user’s authentication token (password) stored in /etc/shadow file.

Linux set or reset user password

To change the password, type the below command and press enter –

# passwd 
Sample Output

(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Linux change password for another user account

To reset or change the password for any other user, type the below command with username and press enter –

# passwd kodehelp
Sample Output
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

As a Linux system administrator (sysadmin) you can change password for any users on your server. To change a password on behalf of a user:

  1. First, sign on or su or sudo to the root account on Linux, run: sudo -i
  2. Then type, passwd jerry to change a password for jerry user
  3. The system will prompt you to enter a password twice as below
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Force Linux user to change password on next login

By default, Linux passwords never expire for users. However, we can force users to change their password the next time they log in via GUI or CLI methods. Execute below command to force user to change password on next login –

# sudo passwd -e jerry
# sudo passwd --expire jerry

The passwd command is used to update or change the user’s password. The encrypted password is stored in /etc/shadow file and account information is in /etc/passwd file.