How to change the root password on CentOS 7 with SELinux enabled

Reboot the system and when you see the Grub menu press 'e'.

Find the line starting with the "linux16".

Replace the "ro rhgb quiet" with "rw init=/sysroot/bin/bash" (or "rw init=/sysroot/bin/sh").

Press Ctrl+x.

When you see the command prompt, type:

# chroot /sysroot
# passwd
# touch /.autorelabel
# sync
# exit
# reboot

If you don't make the file ".autorelabel" you will not be able to login if SELinux is enabled.


Shop Amazon - Used Textbooks - Save up to 90%

*Valentin Stoykov is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to

Popular posts from this blog