68901/how-to-break-root-password-in-centos-rhel-8
Hi Guys,
I have my CentOS virtual machine in my virtual box. But I forgot my root password. How can I change my root password?
Hi@akhtar,
Reboot the system and interrupt the boot loader sequence by pressing any key.
Move the cursor to the entry that needs to be booted.
Press e to edit the selected entry. Move the cursor to the kernel command line (the line that starts with linux, it looks like the below output.
Append rd.break options in the end of the kernel command line. This will break just before control is handed from the initramfs to the actual system.
Press Ctrl+x and reboot the system. At this point, a root shell will be presented, with the root file system for the actual system mounted read-only on /sysroot.
Remount /sysroot as read-write.
$ switch_root:/# mount -o remount,rw /sysroot
Switch into a chroot jail, where /sysroot is treated as the root of the file system tree.
switch_root:/# chroot /sysroot sh-4.4#
Set a new root password here.
# passwd root
Make sure that all unlabeled files (including /etc/shadow at this point) get relabeled during boot.
sh-4.2# touch /.autorelabel
Type exit twice. The first will exit the chroot jail, and the second will exit the initramfs debug shell.
Hi@MD, To configure SSH server to your system, ...READ MORE
Follow the below steps and procedures: Prerequisites Must have ...READ MORE
You can use this: stat -c "%a %n" ...READ MORE
You can use if-else branch to check ...READ MORE
Please check the below-mentioned syntax and commands: To ...READ MORE
Hi@akhtar, Generally, these two commands are used to ...READ MORE
Hi@akhtar, To create new partition you can follow ...READ MORE
Hi@akhtar, In Linux system netstat-tnlp command comes from ...READ MORE
Hi@akhtar, To install nginx in your system, you ...READ MORE
Hi@akhtar, To install python-poster in RedHat/CentOs, you can ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.