Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

How to Change the Root Password in Linux

wikihow.com/Change-the-Root-Password-in-Linux

1. Restart your computer.

2. 2

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.
If you don’t press E before the Grub menu disappears, reboot and try again.
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.

1/6
3. 3

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.
In CentOS and some other distributions, the line may begin with linux16
rather than linux .

4. 4

Move the cursor to the end of the line. Use the → , ← , ↑ , and ↓ keys to
place the cursor right after ro .

2/6
5. 5

Type init=/bin/bash after ro . The end of the line should now look like this:
ro init=/bin/bash .
Note the space between ro and init=/bin/bash .

6. 6

Press Ctrl + X . This tells the system to boot directly to a root-level command
prompt in single-user mode.

3/6
7. 7

Type mount –o remount,rw / at the prompt and press ↵ Enter . This mounts
the file system in read-write mode.

8. 8

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.

4/6
9. 9

Type a new root password and press ↵ Enter . The characters you type won’t
be displayed on the screen. This is normal.

10. 10

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.”

5/6
11. 11

Type reboot –f and and press ↵ Enter . This command reboots the system
normally.

6/6

You might also like