Thursday 22 August 2019

Linux root password hack

linux root password hack(Centos7, Redhat 7, Debian)

1. press any key to hold on to grub screen

2. press "e" to edit the grub file

3.a  add "rd.break" at end of the kernal line
3.b add init=/bin/bash   for debian of the linux line

4. press Ctrl+X

5a. mount -o remount,rw sysroot
5b. mount -o remount,rw / (for debian)

6.  chroot sysroot

7. passwd

8. touch /.autorelabel

9. reboot


Why   mount -o remount,rw sysroot ?
- When system boots in the single user mode the file system are in read-only mode. we cannot change the password in read only mode because these changes needs to be written in /etc/shadow file.

Why touch /.autorelabel?
- Relabel the filesystem for SElinux automatically.

No comments:

Post a Comment