How to Change Password on Linux

Changing a user password on Linux is a relatively simple process — if you know what you're doing. Due to the complex interface, it can be a confusing experience for beginners. In this article, we’ll look at how to change passwords in Linux using two of its most popular operating systems, CentOS and Ubuntu.

What is Linux?

Linux is a family of free, open-source operating systems that can be edited and adapted by its users. Systems like macOS and Windows limit user adaptability: their code is not easily modified. That prevents you from accidentally damaging the system, but it also takes power away from users. Linux offers an alternative.

Linux itself is a “kernel” — the software base around which the rest of an operating system, or distribution, is built. For that reason, you’ll find different operating systems that all run on the Linux kernel.

CentOS vs Ubuntu

When picking between alternative distributions, Ubuntu and CentOS are two popular choices. CentOS is a secure and stable system, built around the template of a previous distribution, RHEL. Its predecessor is still the most popular among corporate Linux users, and CentOS makes good use of its best features.

Ubuntu is also an excellent choice and is ideal for personal use. As well as being a stable, streamlined software, it’s fairly user-friendly, in contrast with other distributions. Ubuntu also benefits from dedicated ongoing support, including regular updates and security patches.

But neither operating system will be particularly useful to users if they can’t change and reset their passwords.

How to change an Ubuntu password

If you already know your Ubuntu Linux password but want to change it, follow these steps:

  1. Press the Ctrl+Alt+T keys together. A Linux terminal will open.

  2. Type sudo passwd root in the terminal.

  3. When prompted, input your current password.

  4. Input the new password you’ve chosen and re-enter it to confirm.

How to reset an Ubuntu password you’ve forgotten

If you’ve forgotten your Ubuntu Linux password and want to reset it, follow these steps.

  1. Restart your device.

  2. Hold down the Shift key when the device manufacturer logo appears.

  3. When the boot menu appears, select the second-top option from the list of kernel versions and click Enter.

  4. Select root and press Enter.

  5. When prompted, type mount –o rw,remount / and press Enter.

  6. When prompted, type passwd and your username (i.e., passwd examplename)

  7. Input the new password you’ve chosen and re-enter it to confirm.

  8. Type shutdown –r and press Enter to reboot your system, completing the process.

How to change a CentOS password

If you’re using CentOS and you want to change your password, follow these steps.

  1. Press the Ctrl+Alt+T keys together. A Linux terminal will open.

  2. Type sudo passwd root in the terminal.

  3. When prompted, input in your current password.

  4. Input the new password you’ve chosen and re-enter it to confirm.

How to change a CentOS password you’ve forgotten

If you’re using CentOS and you want to reset a forgotten password, follow these steps.

  1. Restart your device.

  2. Click Esc.

  3. When the boot menu appears, select the version of Linux you want to use and click E.

  4. Select the line starting with Linux or kernel, and click E.

  5. At the end of the selected line, add one space and type single.

  6. Click Enter: you’ll then be prompted to use the key-command Ctrl-X or B to boot in single-user mode.

  7. When prompted, type passwd and click Enter.

  8. Input the new password you’ve chosen and re-enter it to confirm.

    To reboot and complete the process, type the following commands, clicking Enter after each.

    1. mount / -o remount,ro

    2. sync

    3. reboot

Password security

Whatever operating system you use, password security is essential. Hackers and criminals know that a weak password can give them access to money, private data, and sensitive files. That’s why users on any system or device should ensure that they’re using strong, hard-to-crack login details.

With NordPass, you can generate a complex, randomized password for every account and store them in an encrypted online vault. The service will auto-fill login forms and interfaces, ensuring that you never have to worry about forgetting your password again.

Switching to Linux can give users more power and security. Go the rest of the way with NordPass.

Monica Webster
Verified author
Monica is the spirit of our content team. Her bubbliness and creativity sparkle her articles. She loves to investigate various security related problems and bring useful tips to readers. When she is not writing about technology, she explores art.
Subscribe to NordPass news