Sunday, 7 January 2018

How to break centos 7 root password

Reboot the system and press any key to stop the auto-boot from the default kernel. Press “e” after selecting the kernel line.
grub menu rhel 7

When you are in edit mode, go to the line starting with linux16 and append rd.break to the end of this line.
add rd.break to grub menu rhel 7
Press CTLR+x after appending the rd.break to the kernel. This will reboot the system into emergency mode.
enter into emergency mode rhel 7

First we will remount the sysroot file system in read write mode and then use chroot to got into a chroot :
# mount -o remount,rw /sysroot
# chroot /sysroot
# passwd
changing the root password rhel 7

SElinux relabeling

Make sure that all unlabeled files ( including shadow file ) gets relabeled during booting. Touching the hidden file autorelabel instructs SElinux to relabel the files changed outside of its regular context, like the file /etc/shadow.

# touch /.autorelabel

To flush all cache to disk, type the command:
# sync

Then reboot
# reboot

No comments:

How to Download and Install RHEL8 Beta For Free (Red Hat Enterprise Linux)

RHEL (Red Hat Enterprise Linux) 8 beta was released on November 14, 2018, 4 years after the release of RHEL 7. This tutorial will be showi...