Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| reset_root_password [04 November 2025 / 17:55:07] – [Reset Root Password on CentOS & RHEL] 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 | 1. Reboot and Access GRUB Menu | ||
| Line 12: | Line 12: | ||
| ro | ro | ||
| - | with: | + | |
| rw init=/ | rw init=/ | ||
| 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 | ||
| + | |||
