Centos LOST PASSWORD

A fiend of mine need to access a CentOs machine, but he doesn't have the password.

He does not want to reinstall the machine (whatever the reason)

Is there a way to regain access to the root account ? Without reinstalling ?

There is:
Boot into the GRUB window (some distros require holding "shift" for that) and hit "e" for edit.

Go to the kernel line and remove "quiet splash" and add " init=/bin/bash" and let it boot.
Then once the command prompt is there:
"mount -o remount,rw /"
and
"mount -o remount, rw /proc"

Then (for root password):
"passwd" and subsequently change password
This will set a password for root. [Create a new password for the $USER once it's rebooted and logged in as root].
and don't forget to do:
"sync"
Then "reboot" and login as root to administer the system as wanted.

1 Like

that is a very good solution said by triantares compatible and that wont require anything "extra"

another similar one is also using a Live system:

  • boot in a live system
  • mount the root partition (can be made from thunar)
  • chroot it like: sudo chroot /mnt/mydisk /bin/bash
  • run "passwd" to change the root password
  • umount and reboot in the system

in short, this is a very simple and easy way to "crack" any linux system and to have access to all its data, you got root and full RW (except if the disk is encrypted, that's why is the only way to protect yourself really)

Limitations:

  1. you need a live system
  2. you cannot mount the OS if the partition is encrypted (and you dont have the password, of course)
1 Like