Linux–redhat7/centos 7 forgot root password modification

Source: Internet
Author: User

1. (a) When the boot loader boot option menu is on, click the Keyboard button immediately and boot loader will pause.

(b) Press ' E ', Edit options menu
(c) Move up and down 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-sun16th.lvm.lv=vg_kvm7usb/root rhgb quiet LANG=en_US. UTF-8 Rd.break

(d) At the end of the core command line, add Rd.break .
(e) Press ctrl+x again to reboot with this setting.
After the power-on interactive command environment, is not the normal boot system, the normal boot system mounted in the/sysboo and mounted as read-only, must be re-attached to write, in order to modify the password, the steps are as follows:
(a) Re-mount the/sysroot as readable and writable.
switch_root:/# Mount–o Remount,rw/sysroot
(b) chroot working directory to/sysroot.

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

sh-4.2# passwd Root

(d) Because in this case, SELinux does not start, changes to all files may result in incorrect context of the document, to ensure that the SELinux context is reset

You have to add hidden files under the root directory. Autorelabel.

sh-4.2# Touch/.autorelabel

(e) Exit chroot

sh-4.2# Exit

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

switch_root:/# exit
After rebooting, log in with the modified root password.

Reference

Http://dywang.csie.cyut.edu.tw/moodle23/dywang/download/pdf/rhel7.pdf

Linux–redhat7/centos 7 forgot root password modification

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.