Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
reset_root_password [04 November 2025 / 17:55:07] – [Reset Root Password on CentOS & RHEL] kadekreset_root_password [22 January 2026 / 08:38:29] (current) kadek
Line 1: Line 1:
 ===== Reset Root Password ===== ===== Reset Root Password =====
-==== Reset Root Password on CentOS & RHEL ====+==== On CentOS & RHEL ====
  
 1. Reboot and Access GRUB Menu 1. Reboot and Access GRUB Menu
Line 12: Line 12:
   ro   ro
  
-  with:+  with:
  
   rw init=/sysroot/bin/sh   rw init=/sysroot/bin/sh
Line 33: Line 33:
  
   * Set the new password.   * Set the new password.
 +
 +6. Relabel SELinux Contexts (if enabled)
 +
 +  * If SELinux is enforcing, run:
 +
 +  touch /.autorelabel
 +
 +7. Exit and Reboot
 +
 +  * Run:
 +
 +  exit
 +  reboot
 +
 +==== On Ubuntu ====
 +
 +1. Reboot and Access GRUB Menu
 +
 +  * Reboot the system.
 +  * When GRUB menu appears, select the entry you want to modify and press e.
 +
 +2. Edit the Boot Parameters
 +
 +  * Look for the line that starts with:
 +
 +  linux
 +
 +
 +  * Replace:
 +
 +  ro quiet splash
 +
 +  * or similar with:
 +
 +  rw init=/bin/bash
 +
 +3. Boot into Shell
 +
 +  * Press Ctrl + X or F10 to boot.
 +
 +4. Reset Password
 +
 +  * At the root shell prompt (#), enter:
 +
 +  passwd root
 +
 +  * Enter a new password when asked.
 +
 +5. Remount and Reboot Cleanly
 +
 +  * Ensure the root filesystem is mounted correctly:
 +
 +  mount -o remount,rw /
 +
 +  * Then reboot:
 +
 +  exec /sbin/init
 +
 +  * or
 +
 +  reboot -f
 +