How to reset the root password on CentOS 6 and CentOS 7
If you have lost the root password of your server, this article will help you reset it.
Overview
- Access the VNC Console
- Restart the server and edit kernel boot parameters to boot into single-user mode
- Set a new root password without the old password required
Step 1: Access VNC Console
For a cloud server, find your server in Cloud Servers → Create and Manage in the Customer Portal. For a dedicated server, look in Dedicated Servers → Create and Manage. Open the VNC Console using the button of the same name.


Step 2: Edit kernel boot parameters
CentOS 6 – Dedicated server
Restart the server by pressing Ctrl+Alt+Del in the VNC Console window. After the BIOS menu, a timer appears — press ESC to stop it and access the GRUB boot menu.

Use ↓ and ↑ keys to select your boot line and press e to edit. Select the line starting with kernel /vmlinuz- and press e again.


Add the single parameter at the end of the line.

Press Enter to save, then press b to start the system in single-user mode.
CentOS 6 – Cloud server
Restart the server using Send CtrlAltDel in VNC Console. Press Tab to stop the timer and edit the boot menu.

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


Press Enter to boot into single-user mode.
CentOS 7 – Dedicated server
Restart via Ctrl+Alt+Del in VNC. When the GRUB menu appears, select your boot entry and press e to edit.

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


Press Ctrl+X to start the system in single-user mode.
CentOS 7 – Cloud server
Restart via Send CtrlAltDel in VNC. Select your boot entry and press e to edit.

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


Press Ctrl+X. The system will start in single-user mode.
Step 3: Set a new root password
CentOS 6
passwd root
rebootCentOS 7
chroot /sysroot
passwd root
touch /.autorelabel
exit
reboot