How to break root password in CentOS RHEL 8

0 votes

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?

May 11, 2020 in Linux Administration by akhtar
• 38,260 points
1,913 views

1 answer to this question.

0 votes

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.

Hope this will solve your task.

answered May 11, 2020 by MD
• 95,460 points

Related Questions In Linux Administration

0 votes
1 answer

How to configure SSH server in RHEL/CentOS?

Hi@MD, To configure SSH server to your system, ...READ MORE

answered Mar 30, 2020 in Linux Administration by akhtar
• 38,260 points
1,046 views
0 votes
1 answer

How to increase Swap Memory in CentOS 7?

Follow the below steps and procedures: Prerequisites Must have ...READ MORE

answered Oct 5, 2018 in Linux Administration by Frankie
• 9,830 points
15,939 views
–1 vote
1 answer

How to get octal file permission in linux?

You can use this: stat -c "%a %n" ...READ MORE

answered Jan 3, 2019 in Linux Administration by Omkar
• 69,220 points
2,575 views
0 votes
1 answer

How to take input from user in bash script?

You can use if-else branch to check ...READ MORE

answered Jan 31, 2019 in Linux Administration by Omkar
• 69,220 points
1,138 views
0 votes
1 answer
0 votes
1 answer

What is the difference between ctrl z and ctrl c in command line?

Hi@akhtar, Generally, these two commands are used to ...READ MORE

answered Feb 24, 2020 in Linux Administration by MD
• 95,460 points
47,491 views
0 votes
1 answer

How to create one new partition in my hard disk in Linux?

Hi@akhtar, To create new partition you can follow ...READ MORE

answered Apr 7, 2020 in Linux Administration by MD
• 95,460 points
1,186 views
0 votes
1 answer

not able to run netstat-tnlp in Linux.

Hi@akhtar, In Linux system netstat-tnlp command comes from ...READ MORE

answered Apr 16, 2020 in Linux Administration by MD
• 95,460 points
1,094 views
0 votes
1 answer

How to install nginx web server in CentOS/RHEL?

Hi@akhtar, To install nginx in your system, you ...READ MORE

answered Apr 24, 2020 in Linux Administration by MD
• 95,460 points
841 views
0 votes
1 answer

How to install python-poster in RedHat?

Hi@akhtar, To install python-poster in RedHat/CentOs, you can ...READ MORE

answered Feb 11, 2020 in Linux Administration by MD
• 95,460 points
1,032 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP