You've heard it before: change your password regularly. That can sometimes seem like a pain, but fortunately, changing your Linux password is easy. Today we'll show you how to change the current user's password, other users' passwords, and the superuser password with a few simple commands.

Change Your Own Linux Password

Changing your own password is the easiest, using the passwd command. Open a terminal and enter it like this:

        passwd
    

You'll be prompted to enter your old password before entering your new one.

Changing User Password in Linux

Make sure your new password is sufficiently strong. Hackers come up with unending ways to find and abuse weak passwords.

Read More: The Most Common Tricks Used to Hack Passwords

Change Another User's Linux Password

If you share your computer with multiple users, you can change those users' passwords with the passwd command as well:

        sudo passwd username
    

Swap "username" with the username whose password you want to change. You don't need to know their old password.

Changing Another Linux User's Password

If you're not sure what another user's system username is, you can find out using this command, listing all user accounts on your system:

        less /etc/passwd
    

The file readout will list many users, many more than there are actual people using your system. Those other accounts are system processes, sometimes known as "pseudo-users."

Viewing List of Linux Users

So how do you differentiate between a real user and a system process?

The ID number will be the tell. Your own account in the list should look something like "username:x:1000:1000:Firstname Lastname,,,:/home/username:/bin/bash."

That number, 1000, is your ID number. Human users will have an ID number of 1000 or higher. The others should all have ID numbers below 1000.

Batch Setting Linux Passwords

If you're resetting multiple users' passwords, you can batch reset with the chpasswd command.

        sudo chpasswd
    

You will then need to enter each username in a new line, followed by a colon, and then the password you want assigned to them.

        user1:NewPassword
user2:NewPassword
user3:NewPassword

Hit Ctrl+D when you've entered all of them to initiate the reset.

Prompt a User to Reset Their Password

Perhaps you want another user's password changed, but you don't want to do it yourself, or you want to grant them their privacy in choosing a password. You can force them to change their password on their own with the passwd command accompanied by the --expire or -e argument.

        sudo passwd -e username
    

Linux passwords won't expire on their own without you setting an expiration policy, but issuing this command will immediately label a user's password as expired. In this situation, your Linux system will require the user to change their password the next time they log in.

In the photo below, you can see what their screen will look like after attempting to sign in with their old password.

Resetting Expired Linux Password

Change Root Linux Password

The root password is the password for the Linux root user, which is different from a user with root privileges. Your account has elevated privileges only in the moments when a sudo argument is passed in a command.

Related: The Chmod Command and Linux File Permissions Explained

The root user, however, has unlimited control over your system, meaning it's very easy to accidentally harm your computer with it. Thus, signing in and using it should only happen in emergency situations.

However, if you want to change the root password, you'll need to briefly sign in as the root user with this command:

        su -l
    

OR

        sudo -s
    

Once you're signed in, change the root password using the passwd command:

        passwd
    

You will be prompted to confirm your new password before it's saved.

Exit from the root instance the moment you're finished with it to prevent any accidental and harmful changes.

Resetting a Forgotten Linux Password

If you've forgotten your own password, you'll need someone with an administrative account to change it for you, using one of the above methods. If your account is the only admin user, then you'll need to sign in as root and change it from there.

If you don't know your root password either, then there's not much you can do. To prevent yourself from ever getting into this situation, you should be using one of the many available password managers.

Setting Passwords in Linux

Your new password-changing skills will increase the safety and security of your Linux PC experience.

If you're changing passwords because you're a Linux system administrator, you should look into some practical ways to secure your system beyond strong passwords.