Linux two ways rd.break and init reset the root administrator password

Source: Internet
Author: User
Tags administrator password

Centos7/rhel7 into the single user mode and reset password mode has changed significantly, grub from B to boot into ctrl+x boot.

There are two ways to reset passwords, Rd.break and init.

Rd.break Method:

1, start the time, in the Start screen, the corresponding startup item, the kernel name on the "E";

2, enter, find linux16 beginning place, press "End" key to the last, enter Rd.break, press ctrl+x enter;

3, enter after the command mount, found root for/sysroot/, and can not write, only ro=readonly permission;

4, Mount-o remount,rw/sysroot/, re-mount, after Mount, found R,W permission;

5, chroot/sysroot/change the root;

(1) Echo Redhat|passwd–stdin root change root password for redhat, or input passwd, interactive modification;

(2) There is a CP first copy, and then modify the/etc/shadow file

6, Touch/.autorelabel This sentence is for SELinux to take effect

7, Ctrl+d exit

8. Then reboot

At this point, the password modification is complete

Init method:

1. Start the system

, and when GRUB2 starts the screen display, press the E key to enter edit mode.

2. Add the following at the end of the Linux16/linux/linuxefi parameter line: init=/bin/sh

3. Press Ctrl+x to boot to the shell.

4. Mount file system to writable mode: Mount–o REMOUNT,RW/

5. Run passwd and follow the prompts to change the root password. 6. How to enable SELinux before the system, you must run the following command, or the system will not start normally: Touch/.autorelabel

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

Linux two ways rd.break and init reset the root administrator password

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.