Enter single user mode under CentOS7

Source: Internet
Author: User

Enter single user mode under CentOS7

Centos7 uses grub2, which is different from centos6.x for single-user access. However, because it is not possible to use a real machine environment, it is just a rough description of the following ideas.

Init Method

1. The grub2 interface of centos7 has two entrances: normal system entrance and rescue mode;

2. Modify grub2 boot

Press "e" on the normal system portal to enter the edit mode. Search for the ro line starting with linux16;

Change ro to rw (Change read-only to writable)

Delete the rhgb quiet. (The quiet mode can be deleted if the code line does not exist)

Add init =/bin/sh; (or init =/bin/bash, specify the shell environment)

Press ctrl + x to start the system.

3. Modify the root password

# Passwd # change the password

# Touch/. autorelabel # It is said that selinux updated the label after restarting

# Exec/sbin/init # Start the init process normally

There is also a rd. break method (not tried)

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

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.