Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| reset_root_password [04 November 2025 / 17:54:10] – created kadek | reset_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 |
| * Reboot the system. | * Reboot the system. | ||
| * During boot, when GRUB appears, press **e** to edit the default kernel entry. | * During boot, when GRUB appears, press **e** to edit the default kernel entry. | ||
| - | | + | 2. Edit the Kernel Boot Parameters |
| * Find the line beginning with linux16 | * Find the line beginning with linux16 | ||
| * Replace: | * Replace: | ||
| Line 12: | Line 12: | ||
| ro | ro | ||
| - | with: | + | |
| rw init=/ | rw init=/ | ||
| - | | + | 3. Boot with Modified Parameters |
| * Press Ctrl + X to boot into single-user mode. | * Press Ctrl + X to boot into single-user mode. | ||
| - | | + | 4. Access the System |
| * Once booted, you'll be at a prompt. Run: | * Once booted, you'll be at a prompt. Run: | ||
| Line 26: | Line 26: | ||
| chroot /sysroot | chroot /sysroot | ||
| - | | + | 5. Reset Password |
| * Enter: | * Enter: | ||
| Line 33: | Line 33: | ||
| * Set the new password. | * Set the new password. | ||
| + | |||
| + | 6. Relabel SELinux Contexts (if enabled) | ||
| + | |||
| + | * If SELinux is enforcing, run: | ||
| + | |||
| + | touch / | ||
| + | |||
| + | 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=/ | ||
| + | |||
| + | 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 | ||
| + | |||
