How to Change the Root Password in Linux

Method 1 of 2:

With the Current Root Password

  1. How to Change the Root Password in Linux Picture 1
    Open a terminal window. To do so, press Ctrl+Alt+T,[1] which will open a new terminal window with a command prompt in most Linux desktop environments.
    1. If you're not using a desktop environment, you're already at a command prompt, so proceed to the next step.
  2. How to Change the Root Password in Linux Picture 2
    Type su at the command prompt, and press Enter.[2] A Password: line will open below the command prompt.
  3. How to Change the Root Password in Linux Picture 3
    Type the current root password, then press Enter. When the password is accepted, you'll be brought back to the command prompt as the root user.
    1. If you type the password incorrectly, run su and try again.
    2. Passwords are case-sensitive.
  4. How to Change the Root Password in Linux Picture 4
    Type passwd and press Enter. An Enter new UNIX password: line will appear below the prompt.
  5. How to Change the Root Password in Linux Picture 5
    Type a new password and press Enter. The password you type will not appear on the screen.
  6. How to Change the Root Password in Linux Picture 6
    Retype the new password and press Enter. You will see a message that reads 'password updated successfully.'
  7. How to Change the Root Password in Linux Picture 7
    Type exit and press Enter. This will log you out of the root account.
Method 2 of 2:

Without the Current Root Password

  1. How to Change the Root Password in Linux Picture 8
    Restart your computer.
  2. How to Change the Root Password in Linux Picture 9
    Press E at the Grub menu.[3] The Grub menu appears right after you turn on the computer. In most cases, it only stays on the screen for a few moments.
    1. If you don't press E before the Grub menu disappears, reboot and try again.
    2. This method works for most popular Linux distributions (Ubuntu, CentOS 7, Debian). There are many distributions of Linux, some more obscure than others. If you're not able to get to single-user mode with this method, check your distribution's website for instructions specific to your system.
  3. How to Change the Root Password in Linux Picture 10
    Scroll to the line that begins with linux /boot. Use the and keys to do so. This is the line you'll need to modify in order to boot into single-user mode.
    1. In CentOS and some other distributions, the line may begin with linux16 rather than linux.
  4. How to Change the Root Password in Linux Picture 11
    Move the cursor to the end of the line. Use the , , , and keys to place the cursor right after ro.
  5. How to Change the Root Password in Linux Picture 12
    Type init=/bin/bash after ro. The end of the line should now look like this:
    ro init=/bin/bash.
    1. Note the space between ro and init=/bin/bash.
  6. How to Change the Root Password in Linux Picture 13
    Press Ctrl+X. This tells the system to boot directly to a root-level command prompt in single-user mode.
  7. How to Change the Root Password in Linux Picture 14
    Type mount –o remount,rw / at the prompt and press Enter. This mounts the file system in read-write mode.
  8. How to Change the Root Password in Linux Picture 15
    Type passwd at the prompt and press Enter. Since booting into single-user mode gives you root access, there's no need to pass additional parameters to the passwd command.
  9. How to Change the Root Password in Linux Picture 16
    Type a new root password and press Enter. The characters you type won't be displayed on the screen. This is normal.
  10. How to Change the Root Password in Linux Picture 17
    Retype the new password and press Enter. When the system confirms you've re-entered the same password, you'll see a message that reads 'password updated successfully.'
  11. How to Change the Root Password in Linux Picture 18
    Type reboot –f and and press Enter. This command reboots the system normally.
3.7 ★ | 3 Vote

May be interested

  • How to Find a File in LinuxPhoto of How to Find a File in Linux
    finding a file in a linux system can be difficult if you don't know how. the best way to find files is to utilize several different terminal commands. mastering these commands can give you complete control over your files, and they are...
  • How to Take a Screenshot in LinuxPhoto of How to Take a Screenshot in Linux
    taking a screenshot on linux isn't quite as straightforward as it is on other operating systems, such as [https://www.wikihow.com/category:windows windows] or [https://www.wikihow.com/category:mac macos]. this is because there is no...
  • How to Change the Timezone in LinuxPhoto of How to Change the Timezone in Linux
    this wikihow teaches you how to change the time zone on a linux computer. you can change the timezone on every linux distribution by using the command line, or you can use the selection menu in the command line for different linux...
  • How to Add or Change the Default Gateway in LinuxPhoto of How to Add or Change the Default Gateway in Linux
    your default gateway is the ip address of your router. typically this is automatically detected by your operating system during installation, but you may need to change it. this is especially true if you have multiple network adapters or...
  • How to Install LinuxPhoto of How to Install Linux
    linux is the foundation of thousands of open source operating systems designed to replace windows and mac os. it is free to download and install on any computer. because it is open source, there are a variety of different versions, or...
  • How to Deploy .Net Applications to the Linux Platform With Confidence Using Mono With Delphi PrismPhoto of How to Deploy .Net Applications to the Linux Platform With Confidence Using Mono With Delphi Prism
    .net since inception has captivated developers across the world, with its simplicity in terms of development, and flexibility of deployment of enterprise class applications. today, windows applications are reaching new frontiers in the...