reset root password

When the grub boot loader boot options menu appears, click any key on the keyboard immediately, and the boot loader will pause.

(b) Press 'e' to edit the options menu
(c) Move up and down keys to the linux16 core command line

linux16 /vmlinuz-3.10.0-123.el7.x86_64 root=UUID=449d53d1-84c2-40c0-b05e-d1900591d71b ro rd.lvm.lv=vg_kvm7usb/swap crashkernel=auto

vconsole.keymap=us crashkernel=auto vconsole.font=latarcyrheb-sun16 rd.lvm.lv=vg_kvm7usb/root rhgb quiet LANG=en_US.UTF-8 rd.break

(d) Add rd.break console tty1 at the end of the core command line.
(e) Press Ctrl+x again to reboot with this setting.
●The interactive command environment after booting is not a normal booting system. The normal booting system is mounted on /sysboo and mounted as read-only. It must be remounted as writable before changing the password. The steps are as follows:
(a) Remount /sysroot as readable and writable.
switch_root:/# mount –o remount,rw /sysroot
(b) chroot the working directory to /sysroot.

switch_root:/# chroot /sysroot
(c) Set a new root password.

sh-4.2# passwd root

(d) Because SELinux is not started in this case, changes to all files may cause the context of the document to be incorrect. In order to ensure that the SELinux context is reset at boot, the

The hidden file .autorelabel must be added to the root directory.

sh-4.2# touch /.autorelabel

(e) Exit chroot

sh-4.2# exit

switch_root:/#
(f) Exit the system, the system will automatically reboot.

switch_root:/# exit
reboot After rebooting, use the modified root password to log in.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324929045&siteId=291194637