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 in Linux Administration by akhtar
• 11,270 points
39 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 by MD
• 24,500 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 in Linux Administration by akhtar
• 11,270 points
43 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,810 points
3,765 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,060 points
258 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,060 points
100 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 in Linux Administration by MD
• 24,500 points
402 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 in Linux Administration by MD
• 24,500 points
36 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 in Linux Administration by MD
• 24,500 points
24 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 in Linux Administration by MD
• 24,500 points
30 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 in Linux Administration by MD
• 24,500 points
75 views