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:

Latest Articles

  • PHP2Shell Patching, Migration and Vulnerability Guide With Solutions
  • Firefox PDF Does Not Display - Shows Desktop Or Other App Instead Solution
  • How To Convert HTML to Text Based PDF
  • How To Emulate Android in Linux
  • How to use KVM and GUI inside Docker
  • python spacey ERROR: No matching distribution found for thinc<8.4.0,>=8.3.12
  • Debian 11 security repo fixes due to EOL
  • MySQL vs MariaDB how to create a socket user tutorial
  • Ubuntu Linux Mint Desktop Dark Black Cannot See Solution
  • How to combine .txt ACLs without breaking things
  • How to ping all of Googlebot's IPs script
  • 'virtio0' uses a qcow2 feature which is not supported by this qemu version: QCOW version 3
  • Linux bash script to get the IP of a list of hostnames
  • How To Use Camera Webcam in Docker for OBS Studio etc...
  • Computer Server Won't Post Boot Or Enter BIOS Setup After Installing RAID SAS or GPU Card etc..
  • How To Test PHP Scripts from CLI with GET variables/query string
  • apt-cache how to see all available versions of a package in Debian Ubuntu Mint
  • Virtualbox VBox Guest-utils drag and drop files stops working with Windows VMs
  • How To Remove Ubuntu Netplan and Go Back to /etc/network/interfaces
  • How To Force Flash an AMD Instinct GPU To Another Model Using Debian Ubuntu Mint Linux