# How to reset the root password on CentOS (/docs/tutorials/password-and-authentication/reset-root-password-centos-6-7)







































If you have lost the root password of your server, this article will help you reset it.

### Process overview

1. Access the VNC Console.
2. Restart the server and edit kernel boot parameters to boot the server into single-user mode.
3. Set a new root password without knowing the old one.

### Step 1: Access the VNC Console

1. Log in to the [Customer Portal](https://portal.servers.com)
2. Find your server
   * For a cloud server, go to **Cloud Servers** → **Instances**.
   * For a bare metal server, go to **Enterprise Bare Metal** → **Manage**.
3. In the server details page, click the **VNC Console** button.

## Step 2: Edit kernel boot parameters

To boot the server into single-user mode, you need to edit kernel boot parameters using the GRUB bootloader menu. Menu behavior and boot parameters depend on OS version and whether it's a bare metal server or a cloud server.

#### CentOS 6 – Bare metal server

1. Restart the server using **Send CtrlAltDel** button in the VNC Console. After the BIOS menu, press **ESC** to stop the timer and access the GRUB boot menu.

<img alt="GRUB boot menu on CentOS 6" src={__img0} />

2. Use **↓** and **↑** keys to select your boot line and press **e** to edit.

<img alt="GRUB entry selection on CentOS 6" src={__img1} />

3. Select the line starting with `kernel /vmlinuz-` and press **e** again.

<img alt="Editing kernel parameters in GRUB" src={__img2} />

4. Add the `single` parameter at the end of the line.

<img alt="Single parameter added to kernel line" src={__img3} />

5. Press **Enter** to save, then press **b** to boot the server into single-user mode.

#### CentOS 7 – Bare metal server

1. Restart the server using **Send CtrlAltDel** button in the VNC Console. When the GRUB menu appears, select your boot entry and press **e** to edit.

<img alt="GRUB menu on CentOS 7" src={__img4} />

2. Find the line starting with `linux`, `linux16`, or `linuxefi` (depending on architecture).
   * Change `ro` to `rw`.
   * Remove `rhgb` and `quiet`.
   * Add `rd.break enforcing=0` at the end.

<img alt="CentOS 7 kernel parameters before modification" src={__img5} />

<img alt="CentOS 7 kernel parameters after modification" src={__img6} />

3. Press **Ctrl+X** to boot the server into single-user mode.

#### CentOS 8, CentOS Stream 9 – Bare metal server

1. Restart the server using **Send CtrlAltDel** button in the VNC Console. After the BIOS menu, press **ESC** to stop the timer and access the GRUB boot menu.
   <img alt="GRUB menu on CentOS Stream 9" src={__img7} />

2. Select your boot entry and press **e** to edit.

3. Find the line starting with `linux ($root)/vmlinuz`,  `linuxefi /vmlinuz`, or `linux16` (depending on architecture), and add `rd.break enforcing=0` at the end
   <img alt="CentOS Stream 9 kernel parameters modification" src={__img8} />

4. Press **Ctrl+X** or **F10** to boot the server into single-user mode.
   <img alt="CentOS Stream 9 single-user mode" src={__img9} />

#### CentOS 6 – Cloud server

1. Restart the server using **Send CtrlAltDel** button in the VNC Console. Press **Tab** to stop the timer and edit the boot menu.

<img alt="GRUB cloud server boot menu CentOS 6" src={__img10} />

2. Remove the highlighted parameters and add `1` (with a leading space) at the end of the string.

<img alt="Removing parameters from boot line" src={__img11} />

<img alt="Modified boot parameters on cloud server" src={__img12} />

3. Press **Enter** to boot the server into single-user mode.

### CentOS 7 – Cloud server

1. Restart the server using **Send CtrlAltDel** button in the VNC Console. When the GRUB menu appears, select your boot entry and press **e** to edit.

<img alt="Cloud server GRUB menu CentOS 7" src={__img13} />

2. Change `ro` to `rw`, remove highlighted parameters, and add `rd.break enforcing=0` at the end.

<img alt="Before removing parameters on CentOS 7 cloud" src={__img14} />

<img alt="After modifying parameters on CentOS 7 cloud" src={__img15} />

3. Press **Ctrl+X** to boot the server into single-user mode.

#### CentOS 8, CentOS Stream 9 – Cloud server

1. Restart the server using **Send CtrlAltDel** button in the VNC Console. When the GRUB menu appears, select your boot entry and press **e** to edit it before the boot timer expires.

2. Find the line starting with `linux`, `linux16`, or `linuxefi` (depending on architecture), and make the following changes:
   * Change `ro` to `rw`.
   * Remove the parameters highlighted in red.
   * Add `rd.break` at the end of the line.
     <img alt="Modifying parameters on CentOS 8, CentOS Stream 9" src={__img16} />

3. Press **Ctrl+X** to boot the server into single-user mode.

## Step 3: Set a new root password

If the kernel boot parameters were modified successfully, the server boots into single-user mode and displays a prompt similar to `switch_root:/#`.

#### CentOS 6

```bash
passwd root
reboot
```

### CentOS 7

```bash
chroot /sysroot
passwd root
touch /.autorelabel
exit
reboot
```

#### CentOS 8, CentOS Stream 9

**Bare metal server**

1. Remount the root file system in read-write mode:

```bash
mount -o remount,rw /sysroot
```

2. Switch to the installed system:

```bash
chroot /sysroot
```

3. Change the root password:

```bash
passwd root
```

4. Create a file to trigger automatic SELinux relabeling after the next reboot:

```bash
touch /.autorelabel
```

5. Exit and reboot the system:

```bash
exit
reboot
```

6. Log in as root with the new password:
   <img alt="CentOS Stream 9 root user" src={__img17} />

**Cloud server**

```bash
chroot /sysroot
passwd root
touch /.autorelabel
exit
reboot
```
