How to change the password in Linux systems? The passwd utility in Linux helps you to reset the password settings for a user profile. The /etc/shadow file stores encrypted passwords of the users and other details related to the password. As a regular person, you can change your password. The root user and users with sudo privileges can change other members' passwords and decide if they should be used or changed. Make sure you use a clear and special password when changing your password.
Using a secure password is by far the most crucial thing you can do to safeguard your account. When creating a password, it should contain at least:
- an uppercase letter
- a lowercase letter
- an integer
- a special character
- at least sixteen characters
It is recommended that you change your password daily and use a different password for each account's security purposes.
How to Change Password Linux
We will describe two different procedures to change passwords in Linux
How to Change User Account Passwords [Linux change user password]
Execute the passwd command in Linux without any arguments or parenthesis to change the password of your user account:
Your existing password would be required to be entered. If the password is correct, the command will tell you to create a new user password and validate the password. While entering your password, it is not shown on the window. Use the same password in your future login sessions.
How to Change Password of Another User on System
Only the system administrator and administrators with Sudo privileges can change the password to every other user account.
The following explanation assumes you have sudo rights and are logging in as that account.
Execute the command passwd, followed by the system username, to modify the password of the different user accounts. To modify the password of a user named urn, for example, execute the given command below:
sudo passwd urn
You'll be prompted to enter and validate your new password. If the command is executed successfully, it will print the following line:
passwd: password updated successfully
Modification by Force
By default, credentials are configured never to expire. To encourage the individual to change their password the next time they start a login session, use the passwd command with the --expire option accompanied by the person's username:
sudo passwd --expire urn
If you use the command above, the user password will subsequently expire.
The user will be prompted to update their password the next time they want to log in using their old password:
WARNING: Your password has been expiring.
You must now change your password and re-login!
For urn, you will be modifying the password. After the user has set a new password, the interface will be disabled.
So this is how you can easily change passwords in Linux and set password expiration. Changing passwords is very helpful for the admin or the root user to maintain the password conditions and send a notification once the password expiration date is exceeded.
For further reading, I think you will like the following: