This guide will cover the procedure to reset root password in CentOS7 using the emergency mode. Let’s begin!
To reset the password, follow the below-mentioned steps:
- Reboot the server, you will see the grub menu.
- Press “e” to edit. You will see the edit screen as shown below.
- Find the line starting with linux16:
linux16 /boot/vmlinuz-3.10.0-1160.76.1.el7.x86_64 root=UUID=1c419d6c-5064-4a2b-953c-05b2c67edb15 ro no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop crashkernel=auto LANG=en_US.UTF-8
In the fine section, find
Delete everything after that and replace with “
rd.break”, so the line looks like the following
linux16 /boot/vmlinuz-3.10.0-1160.76.1.el7.x86_64 root=UUID=1c419d6c-5064-4a2b-953c-05b2c67edb15 ro rd.break
- Boot the system to the emergency mode by pressing CTRL + X, you will get a prompt like the following
/sysrootin read-write mode. and chroot to the file system
mount -o remount,rw /sysroot
- Reset the root password with
- Now reboot the system by typing the “exit” command two times
After rebooting, you will be able to log in to the system with the new root password.
After implementing the procedure mentioned in this guide, one can easily reset root password in CentOS 7 using emergency mode