If you are a system administrator managing a CentOS/RHEL server, you may encounter situations where you need to reset a user’s password. This could be because the user has forgotten their password or for security reasons. In this guide, we will show you how to reset a user’s password on CentOS/RHEL using the passwd command.
Step 1: Log in as root
To reset a user’s password, you need to have root privileges on the server. Log in to the server as the root user.
Step 2: Choose the user account
Next, choose the user account whose password you want to reset. You can do this by typing the following command:
# passwd username
Replace “username” with the actual username of the user whose password you want to reset.
Step 3: Enter the new password
After executing the above command, you will be prompted to enter a new password for the user. Enter the new password and then confirm it by entering it again.
Step 4: Confirm the password change
After entering the new password, the system will confirm that the password has been changed successfully.
Step 5: Test the new password
To make sure that the new password is working, log out of the server and log back in using the user’s account and the new password.
Optional: Force password change at next login
If you want to force the user to change their password at the next login, you can use the following command:
# chage -d 0 username
This will set the user’s password to expire immediately, forcing them to change it the next time they log in.
- passwd – command to change a user’s password
- chage – command to change user password expiry information
In this guide, we have shown you how to reset a user’s password on CentOS/RHEL using the passwd command. Remember to choose a strong password and to inform the user of the new password if you reset it for them. If you want to force the user to change their password at the next login, you can use the chage command.