How to Change Your Linux Password

View Hidden Passwords Behind Asterisks in Chrome and Firefox

If you’ve been using the same Linux password for a while, it might be time for a change. If you want to change your Linux password, follow this guide.

Once you’ve set up a new Linux PC, one of your first tasks should be to change your Linux password. After all, one of the most important parts of keeping your computer secure is creating a secure password that others can’t guess or crack.

Whether you’re running macOS, Windows, or Linux, it’s crucial to be mindful of your password and change it regularly. So, how do you change your password in Linux? It’s a pretty straightforward process, so let’s take a look.

Recommendations for Strong Passwords

No matter what platform you’re on, strong passwords are vital to keeping your information secure. You should follow some basic precautions and routines, which will help reduce the chances of a security breach. These include:

  • Change your passwords regularly. As a general rule, it’s wise to change your password at least every 90 days. Many experts actually recommend password changes once a month.
  • Use strong passwords. The strongest password will always be more than eight characters long. In truth, the longer the better, but there are often limits to how many characters you can use. For tips on creating strong passwords that you can still remember, be sure to check out our guide on that very subject. One additional suggestion is to make sure your password incorporates a mix of lower case letters, capitalized letters, numbers, and symbols.
  • Never reuse passwords. Using the same password on multiple computers or websites is a dangerous habit to get into. Sure, it may make it easier to remember your passwords, but it also increases the threat if someone guesses it. Use unique passwords everywhere, and make sure you don’t use the same passwords again when you change them.

If you’re happy to follow these typical rules, you shouldn’t have any problem coming up with a secure password for your Linux PC.

How to Set a Linux Password Using the Terminal

The simplest way to set a new Linux password is to use the passwd command in a terminal or SSH window. To use it, open a new terminal window, or connect remotely using SSH (if you’re able to do this).

To set a new Linux password using passwd:

  1. Open a new terminal window or SSH connection.
  2. Type passwd, then press Enter/Return.
  3. You’ll be asked to enter your current password, so do that.
  4. Next, type in your new password.
  5. Finally, re-enter your new password.

That’s all it takes to change your own password, but what if you want to change the password for another user account? Assuming you have sudo privileges, that’s still easy.

To set another user’s password on Linux:

  1. From the terminal, enter the command sudo passwd username, replacing username with the name of the user you want to set a new password for.
  2. If you’re prompted for your password, enter it.
  3. Next, type the new password for the account.
  4. Finally, enter the new password again to confirm it.

Note that the above steps can be used to change the password for the root user, too. When you go through the process, you’ll enter the command sudo password root.

Additional Password Administration Using passwd on Linux

There’s quite a bit more you can do with the passwd command in Linux. If you have multiple accounts on your PC, you can lock a password so the user can no longer use it (they can still use an SSH public key authentication for remote connectivity).

You can then unlock the password, allowing the user to log in that way again. If someone’s forgotten their password, you can delete it so they can log in and set a new one.

Here’s a quick look at some of actions you can perform using passwd:

  • Lock a password: passwd -l <username>
  • Unlock a password: passwd -u <username>
  • Delete a password: passwd -d <username>

In all examples, replace the <username> example with the username you’re administering.

Other options will let you set how many days must pass before the user can change a password, how long a password remains valid before expiring, and more. These options are likely beyond the scope of this how-to, but checking the man file for passwd will give more information.

How to Use GUI Tools to Change Passwords on Linux

Both Gnome Desktop and KDE have tools for user management, including changing your password, using a graphical user interface. If you’re more comfortable using point-and-click methods to change your Linux password, here’s how to make that happen.

In Gnome, Use the Users Application

If your Linux install uses Gnome Desktop (like Ubuntu), you can change your password from the Users section of Settings. It’s important to note that you cannot change the root user’s password this way.

There are more steps involved than changing your password from the terminal, but this is a good option for anyone looking to avoid opening the terminal.

To use Users to change the password on Ubuntu:

  1. Click the Power Button icon in the top-right section of the menu bar.
    Accessing Ubuntu's Settings app
  2. You’ll open a menu including volume and network controls, among other options. From here, click Settings.
    Ubuntu Choose Settings
  3. Scroll down until you find Users, then select it from the list.
    Ubuntu Users in Settings
  4. If you have multiple users, click the one you want to change the password for.
  5. Click anywhere on the Password field to bring up a password change dialog.
  6. Enter your current password, your new password, and confirm the new password.
  7. Click Change to confirm.
    Ubuntu Change Password

Changing Passwords in a KDE Environment

If you’re running a KDE desktop environment (eg. Kubuntu), there’s a GUI tool available to change your password. This only supports user passwords—you can’t change the root password here.

To change your password using KDE:

  1. Click the System Settings icon in the bottom taskbar.
    Kubuntu System Settings Icon
  2. Find and click Users from the menu.
    Accessing the Users settings to change Linux password on Kubuntu
  3. Click on the user you wish to change the password for, then click Change Password.
    Kubuntu Change Password
  4. Enter the new password twice, then click Set Password.
    Kubuntu Password Dialog

Setting a Password Policy You Can Live With

The steps above should help you to change your Linux password. Make sure to set up a password policy on your Linux PC that offers you plenty of security, but gives you a password that you can still live with. Changing passwords daily won’t help much if you use sticky notes to remember them, for example.

You should also try to avoid passwords that are easy to guess—as long as you can remember it. You may want to consider using a password manager, such as 1Password or Enpass, to help you generate and remember new passwords. Both of these apps, and others, are available on Linux, but also support other platforms including Windows, Android, iOS, and macOS.

Finally, whenever possible, take advantage of Two-Factor Authentication (2FA) on your PC and your accounts. This helps tremendously if your password does get compromised, since it requires your confirmation on another device before it can be used.

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *


To Top