Centos7/rhel7 reset the root password (rd. break and init methods), centos7rhel7

Source: Internet
Author: User

Centos7/rhel7 reset the root password (rd. break and init methods), centos7rhel7

The single-user access mode and password reset mode for centos7/rhel7 have greatly changed. GRUB is changed from B-guided to ctrl + x-guided.

There are two methods to reset the password: rd. break and init.

 

Rd. break method:

1. at startup, on the startup interface, press "e" on the corresponding startup Item and kernel name ";

2. After Entering, find the place starting with linux16, press the "end" Key to the end, enter rd. break, and press ctrl + x to enter;

3. Enter the mount command and find that the root is/sysroot/and cannot be written. Only the ro = readonly permission is required;

4. mount-o remount, rw/sysroot/, re-mount, and then mount, and find that the r and w permissions are available;

5. Change the root of chroot/sysroot;

(1) echo redhat | passwd-stdin root: Change the root password to redhat, or enter passwd for interactive modification;

(2) cp and then modify the/etc/shadow file.

6. touch/. autorelabel takes effect for selinux.

7. Press ctrl + d to exit

8. Then reboot

So far, the password has been modified

 

 

Init method:


1. Start the system and press e to enter the editing mode when GRUB2 starts the screen display.

2. Add the following content at the end of the Parameter Line of linux16/linux/linuxefi: init =/bin/sh

3. Press Ctrl + x to start to shell.

4. mount the file system in writable mode: mount-o remount, rw/

5. Run passwd and change the root password as prompted.
6. If selinux is enabled in the system, you must run the following command. Otherwise, the system cannot be started properly: touch/. autorelabel.

7. Run the exec/sbin/init command to start the instance normally, or run the exec/sbin/reboot command to restart the instance.

 

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.