CentOS 7 Root User Password Reset, centos2017-04-02

Source: Internet
Author: User

CentOS 7 Root User Password Reset, centos2017-04-02

Cross-platform collection: http://www.cnblogs.com/dunitian/p/4822808.html#linux

 

At startupPress e(If you are using reboot, you can enter reboot and press enter to enter this page)

Press the down arrow directly (we need to add something at the bottom)

Find Linux16,Add init =/bin/sh at the end(In the 16 line, press the end key to the end. Remember to add a space), and press ctrl + X to enterSingle User Mode(A bit like restoring SQL Server)

Mount-o remount, rw/Mount the root directory to the readable and writable mode.

PasswdReset the Root password, enter the password, and then confirm the password (I don't know why, do you think Centos is like this now, remember that it was previously prompted in English)

Touch/. autorelabelCreate System File. autorelabel, touch this command before I said, the basic command can look at this (Click me) http://dnt.dkill.net/dnt/linux/cmd.html

Exec/sbin/initInitialize and start the system

Enter the password ~ OK

Extended Description: on the internet, CentOS7 can no longer be restored using this traditional method. For example, I seem to be able to use it. Maybe it is not possible. paste other methods on the Internet:

In CentOS 7 & RHEL 7, the single-user access mode and password reset mode have greatly changed. GRUB is changed from B-pilot to ctrl + x-pilot.

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.

 

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.