Overview
Applies To
CentOS 7, RHEL 7; Tested on CentOS 7Pre-requisites
Console Access to the system.Choose Kernel Entry - Core
In order to reset the root password, you need to reboot the server and choose “Core” kernel entry in the “boot” menu option.When the boot menu is shown; choose the kernel entry as below and press key “e” as shown below.
CentOS Linux (3.10.0-229.11.1.el7.x86_64) 7 (Core)
Note: Boot screen will be shown only for 5 seconds.
Find Kernel Entry – ro
In the “Edit Kernel” option, navigate till you find text “ro” after root device mapper.Modify Kernel Entry – init
Next, you need to modify the kernel entry as below; which will instruct the kernel to start server into “sh”. To boot the server in single user mode, add the below entry.rw init=/sysroot/bin/sh
After modifying, press “Ctrl + x”, kernel will be instructed to start in single user mode.
System booting .....
Change Root – sysroot
Execute chroot command or interactive shell with special root directory. Run the command as below;chroot /sysroot/
Set – Root Password
Now, After running the “chroot” command; in the shell prompt run the command “passwd” along with login username “root” as below to set new password for the root user.After command execution, Enter the new password and re-enter the new password again.
passwd root
Relabel Filesystem – SELinux
At boot time, init.rc checks for the existence of /.autorelabel. If this file exists, SELinux performs a complete filesystem relabel (using the /sbin/fixfiles -f -F relabel command); and then deletes file /.autorelabel.To perform the check run the command and reboot the server; after rebooting you can login into the server with newly set password.
touch /.autorelabel
reboot
No comments:
Post a Comment