This is one of the most repeated questions we receive a lot on our website.” I forgot my password, can you help me change it???”. Contrary to what most think, you can change the password easily in no time. Let’s dig deep and show you everything you need to know about the Linux password.
By the end of this tutorial, you will be able to gain some information about how the password is saved in the Linux systems. Also, you will be able to change your password and other users’ passwords. Changing the password can be done using one of the following methods:
- via the command line
- via the graphical user interface
Where is the Linux password stored?
However, before changing the password, let’s check first where the password is stored in Linux. As a Linux user, you should know that the password for any Linux user account is saved into two main password configuration files:
- The /etc/passwd file
- The /etc/shadow file
The/etc/passwd file contains all the Linux system users, each user home directory, group, and some other information about each user account. In this file, you can see so many users, but in fact, some of these users can log in because the other users are locked until you unlock them. To preview the content of the /etc/passwd file, you can easily use the following command:
cat /etc/passwd

As you can notice, the /etc/passwd file contains so many users that you are not using, and the most probably you do not know they even exist. You can scroll down till you reach a row for your user account.

Previously, the encrypted passwords for each user account were stored in the /etc/passwd file. Nowadays, they are removed from the /etc/passwd file and added to the /etc/shadow file. To preview the content of the /etc/shadow file, you should use the “sudo” command as follows:
sudo cat /etc/shadow

As you can observe, for each entry in the /etc/passwd file, you will find another corresponding entry in the /etc/shadow file. Also, the /etc/shadow file will contain the last time the password was changed and some other information.

Now before moving on to the next section, let’s check how to create a strong password.
What is a Strong Password?
It is highly recommended that you use a strong password so that it will not be hacked easily. Try to design a unique and long password that satisfy the following conditions:
- Avoid using any of your personal information like your name, ID, mobile number, birth date, your pet name, etc.
- Create a unique password for each account you use as the password for bank account should not be the same as your Linux account or email account and so on.
- Pick a famous quote or something like a line from your favorite song or movie or book.
- Make sure to use lower and upper case letters like A, a, B, b, C, c, etc.
- Make sure to include numbers in the password like 0, 1, 2, etc.
- Make sure to use various special characters in the password like @, $, #, and so on.
With that in mind, let’s move on to know how to change the password.
Change the Linux Password
Change Password via the Command Line or Terminal
During this method, we will be using the passwd command to change your current user account and other users’ passwords too. But be careful, it is highly recommended that you write down the password before logging out.
Change Your Current Password
Step 1. First things first, let’s open a terminal.
Step 2. To change the password of the currently logged-in user, use the next command:
passwd

Step 3. As you can notice, to be able to change your password, you will be asked to enter your current one first.

If everything is ok, you will get a message that your password is updated successfully.
Change Another User Password
Use the passwd command along with the user account you need to change his or her password.
sudo passwd User_Account

Unlike changing your password, you will not be asked to enter the user’s password. However, you will be asked directly to enter the new password for the mentioned user.
Additionally, in case you need to change the root password use the next command:
sudo passwd root

Force User To Change Password
One more thing, if you need to force a user to change his or her password at the next time he or she logs in using the passwd command with the “-e” option as follows:
sudo passwd -e User_Account

You will be informed that the user will be asked to enter a new password they log in.
Change Password via Graphical User Interface
In this method, you will be using the built-in settings application to change your password.
Step 1. From the top right of your desktop, click on the drop-down arrow.

Step 2. Press the system settings button.

Step 3. From the left panel, scroll down until you find the Details option.

Step 4. From the left panel, select the Users option.

Step 5. You will get a screen like the below one with all the defined users appears as follows:

Step 6. To edit any of those, users press the Unlock button on the top of the settings screen. Also, you will be asked to enter the sudo password.

Step 7. Suppose you need to change your current password, you will double click on the password field.

Step 8. Now you will be prompted to enter the current password and the new one.

Step 9. If your password is strong enough, you will be able to save it using the Change button.

Step 10. Additionally, to change another user password, click on the user and double click on the password field.

Congratulations, you have just learned a new skill that you can use to master your Linux quickly. That’s it for now for any further questions leave a comment, and we will be glad to help you with it.
” I forgot my password, can you help me change it???”
You never did answer THAT question. If you do not remember your current password, you cannot change it. Only someone with root privileges can.