How to change the Linux Password

Are you eager to learn how to change the Linux password? Let's cut to chase and show you where the Linux password is stored and how to change it by command-line and GUI ways.

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

The passwd File Content
The passwd File Content

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.

The tuts User Account
The tuts 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

The shadow File Content
The shadow File Content

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.

The tuts User Account in The shadow File
The tuts User Account in The shadow File

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

Change Current Password
Change Current Password

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

Current Password Changed Successfully Using passwd Command
Current Password Changed

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

Change Password For Another User Account
Change Password For Another 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

Change Password For Root Account
Change Password For Root Account

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

Force User To Change Password
Force User To Change Password

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.

Press the Drop Down Arrow
Press the Drop Down Arrow

Step 2. Press the system settings button.

Open the System Settings
Open the System Settings

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

Select The Details Option
Select The Details Option

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

Open the Users Menu
Open the Users Menu

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

Users on The Ubuntu
Users on The Ubuntu

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.

Unlock The Settings Screen For Editting
Unlock The Settings Screen For Editing

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

Double Click on The Password Field
Double Click on The Password Field

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

Enter The Required Fields
Enter The Required Fields

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

Press The Change Button
Press The Change Button

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

Change The tuts User Account
Change The tuts User Account

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.

Hend Adel
Hi! I'm Hend Adel, a freelancer technical geek with successful experience in Database, Linux and many other IT fields. I help to build solutions to suit business needs and creating streamlined processes. I love Linux and I'm here to share my skills via FOSS Linux! Thanks for reading my article.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

23,241FansLike
394FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

MUST READ

The Ubuntu Cinnamon Remix brings together Linux Mint's Cinnamon desktop with the Ubuntu Core. While some users are welcoming the new flavor of Ubuntu with open arms, others are scratching their heads, wondering where it fits in.
The wait is finally over (almost) for all you Ubuntu fans out there. The latest version of Ubuntu, 20.10 codenamed "Groovy Gorilla," is currently available in the beta version. I have tested out the distro myself, and it is stable enough to take out for a spin.

Ubuntu Cinnamon Remix Review

The Ubuntu Cinnamon Remix brings together Linux Mint's Cinnamon desktop with the Ubuntu Core. While some users are welcoming the new flavor of Ubuntu with open arms, others are scratching their heads, wondering where it fits in.

6 ways to find out your Linux file system type

Any Operating system in the market whether its Windows, Linux, Unix, macOS, and any other, must be able to access and manage files and data on storage devices.

CentOS vs. Fedora: Key Differences

Both Fedora and CentOS are RPM-based Linux distributions. The two share a lot of features in common but still have several differences. In this post, we introduce both Fedora and CentOS and look at their key differences in this comparison article.

Top 5 reasons to switch from Windows to Linux right now

Do you love Windows or Linux? Being on a Linux website, it's not hard to take a guess, but what are the strong reasons to switch to Linux? Linux is a 100% free OS. Is that reason alone enough? Let's find out! Never have there been more compelling reasons to make the switch. Here are just five great reasons for users to create that magical move from the wayward world of Windows to the lauded land of Linux.