May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Booting into single user mode and changing root password Centos / Redhat 7

During boot, press “e” at the grub loader.
Scroll down using the arrow keys to the line starting with “linux”. It would look like this.
linux16 /vmlinuz-3.10.0……
Remove the following from that line. “rhgb” and “quiet“.
Add the following to the end of the line. “init=/bin/sh“.
Press ctrl+x to continue the boot process.
Once the system is booted, you will be at the root user in single user mode. But this is in a read only file system.
You need to mount the / filesystem.
mount -o remount, rw /
Test that you can write to /, following command should work without error.
touch /tmp/test
Now change your password for root
passwd
Touch the following file to make sure things are ok on SELinux, this is a fix file process.
touch /.autorelabel
Finally start the normal boot process.
exec /sbin/init

You’re Done.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>