In today’s digital age, protecting your sensitive personal information is more important than ever. And having strong passwords definitely helps protect your personal data from prying eyes. In this article, we will discuss two different methods to change passwords in Linux for both yourself as well as for other users.
Change Password Using the GUI in Linux
The GUI method suits best for new users and beginners. Generally, different Linux distributions have different styles of GUIs, but most of them share some common methods to change the password for a user. We have shown the method to change the password on GNOME:
1. Open Settings from the application menu.
2. Scroll down and select the “Users” option from the left sidebar.
3. Next, select the username you want to change the password for.
4. Click on the “Unlock…” button on the top right corner to enter “Admin Mode” with your root password.
5. Click on the “Password” menu from the “Authentication and Login” sub-section. This will open a new dialogue box named “Change Password.”
6. Select the “Set a password now” radio button and enter a new strong password. You can also click on the gear icon on the right of the text box to generate a random strong password (make sure to note it down somewhere). Then, input the same new password in the “Confirm New Password” field. Finally, click the “Change” button in the top right corner to apply the changes.
Change the Password for a Single User in Linux
Change Password Using the passwd Command
Using the passwd command to change the user password is the most common way to do so, all thanks to its simple syntax and usage. If you need to change the password of any user other than yourself, you need to have root permissions or be a super user. Here’s how you can use passwd command in Linux:
1. Open the terminal and execute the
passwd command as:
sudo passwd <username_to_change_password>
For example, to change the password for the user “test”, use this command:
sudo passwd test
2. Then, type a new strong password with a combination of uppercase, lowercase, special characters, and numbers, and then hit Enter. For security reasons, the new password which you are typing will not be visible.
3. Next, you will get a prompt to retype the new password. Type the new password again and hit Enter.
4. Finally, you will see the following message to confirm the change.
passwd: password updated successfully
Note: If you omit the username in the command, then the password will get changed for your account.
Change Password Using the usermod Command
The usermod command is a handy tool that is generally used to modify a user’s account, but it can also be used to change the password in Linux.
1. Open the terminal and type the following command with this syntax:
sudo usermod -p <new_password> <username_to_change_password_for>
For example, to change the password for the user named “test” to 1234, use this command:
sudo usermod -p 1234 test
2. Next, type the sudo password and hit Enter.
3. The password for this user will get changed.
How to Change Linux Password for Multiple Users
If you need to change passwords for a batch of users, Linux comes with a very handy tool named
chpasswd, which stands for change-password. Use these steps to change the password for multiple users in Linux:
1. Open the terminal and type this command:
2. Now, type the usernames and their respective new passwords with this syntax to update the passwords for different users:
<user_1>:<new_password_1> <user_2>:<new_password_2> <user_3>:<new_password_3>
3. When done, press the “CTRL + D” key on the keyboard to apply the changes.