Debian Mint Ubuntu Linux Server Password Forgotten Reset Password Solution Centos 7 8 Root Password Reset Recovery

This guide will work for most modern Linux versions like Centos RHEL 7, Debian, Mint, Ubuntu etc...

In Centos 7 the days of editing the "kernel" line and adding "single" are gone.  On top of that sometimes after a new install passwords do not work, maybe you forgot your password or for some other reason you need to break in or fix your system?  It could also be because you can't mount your root / or some other /etc/fstab error and many other errors.

Step 1.) Enter GRUB Boot Menu

Reboot your server/computer and keep hitting the "Left Shift" key until you get the GRUB screen like this.

Hit "e" to Edit on the screen below.

 

Step 2.) Edit GRUB Boot Options

Navigate to the first line that starts with "linux" as shown in red.

Move your cursor to the "ro" portion.

 

For CentOS/RHEL based do this:

Replace "ro" with "rw init=/sysroot/bin/sh" and boot as below and hit "Ctrl+X"

 

With CentOS you need to chroot to /sysroot, then you can work as you need and expect in the root of the mounted filesystem.

For Debian/Mint/Ubuntu based do this:

rw init=/bin/bash

*Be sure to erase the $vt_handoff or it will not boot into bash

The boot line should look like this below.

 

With Mint/Debian/Ubuntu it mounts the root filesystem as you'd expect.  With CentOS you need to chroot to /sysroot

 

Short Version:

1. Edit your grub settings and find the linux16 /vmlinuz and then the "ro" portion.

2. Replace "ro" with "rw init=/sysroot/bin/sh" and boot.

3. Type chroot /sysroot to enter your OS environment to fix/change things.


Long Version:

  1. 1.) On bootup edit the bootline by entering GRUB.
  2. Type e
  3. Find the line that says "linux16 /vmlinuz"
  4. Edit the part that says "ro" and change with "rw init=/sysroot/bin/sh"
  5. Hit "Ctrl-X"
  6. Upon bootup type "chroot /sysroot"
  7. password
  8. touch ./autorelabel
  9. exit
  10. reboot

 


Tags:

centos, password, resetin, editing, quot, kernel, adding, install, passwords, requirements, installer, bootup, edit, bootline, grub, linux, vmlinuz, ro, rw, init, sysroot, bin, sh, ctrl, chroot, autorelabel, reboot,

Latest Articles

  • How high can a Xeon CPU get?
  • bash fix PATH environment variable "command not found" solution
  • Ubuntu Linux Mint Debian Redhat Youtube Cannot Play HD or 4K videos, dropped frames or high CPU usage with Nvidia or AMD Driver
  • hostapd example configuration for high speed AC on 5GHz using WPA2
  • hostapd how to enable and use WPS to connect wireless devices like printers
  • Dell Server Workstation iDRAC Dead after Firmware Update Solution R720, R320, R730
  • Cloned VM/Server/Computer in Linux won't boot and goes to initramfs busybox Solution
  • How To Add Windows 7 8 10 11 to GRUB Boot List Dual Booting
  • How to configure OpenDKIM on Linux with Postfix and setup bind zonefile
  • Debian Ubuntu 10/11/12 Linux how to get tftpd-hpa server setup tutorial
  • efibootmgr: option requires an argument -- 'd' efibootmgr version 15 grub-install.real: error: efibootmgr failed to register the boot entry: Operation not permitted.
  • Apache Error Won't start SSL Cert Issue Solution Unable to configure verify locations for client authentication SSL Library Error: 151441510 error:0906D066:PEM routines:PEM_read_bio:bad end line SSL Library Error: 185090057 error:0B084009:x509 certif
  • Linux Debian Mint Ubuntu Bridge br0 gets random IP
  • redis requirements
  • How to kill a docker swarm
  • docker swarm silly issues
  • isc-dhcp-server dhcpd how to get longer lease
  • nvidia cannot resume from sleep Comm: nvidia-sleep.sh Tainted: Linux Ubuntu Mint Debian
  • zfs and LUKS how to recover in Linux
  • [error] (28)No space left on device: Cannot create SSLMutex Apache Solution Linux CentOS Ubuntu Debian Mint