Author Topic: reset password root on centos 7.x  (Read 7653 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2145
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
reset password root on centos 7.x
« on: กันยายน 27, 2017, 06:48:35 PM »
The first step to reset the root password is boot the CentOS machine in emergency mode,
and for this process, we’ll use rd.break.
 
Start the system and, on the GRUB 2 boot screen,
=> press the ‘e’ key for edit:

Remove the rhgb and quiet parameters from the end, or near the end, of the linux16 line, or linuxefi on UEFI systems.
=>          linux16 bah bah bah...

Add the following parameters at the end of the linux16 line on x86-64 BIOS-based systems,
or the linuxefi line on UEFI systems: rd.break enforcing=0

add this end of line=>   rd.break enforcing=0

​When you finish, press ctrl + x to load the system. Finally you’ll boot in emergency mode.

#mount -o remount,rw /sysroot
#chroot /sysroot
#passwd

If the system is not writable, the passwd tool fails with the following error:
Authentication token manipulation error
#touch /.autorelabel

#mount -o remount,ro /
and type exit 2times
#exit
#exit

​If you omitted to relabel files enter the following command to restore the /etc/shadow file's SELinux security context:
#restorecon /etc/shadow

Enter the following commands to turn SELinux policy enforcement back on and verify that it is on:
#setenforce 1
#getenforce
show "Enforcing"
Done