Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Enter single-user mode under CentOS7

Shulou Source: shulou.com Published: 2022-06-01 04:49:09 10月05日 Update

Centos7 uses grub2, which is different from centos6.x's approach to single-user access. However, because it is a real machine environment, it cannot be captured, so it is only a rough description of the following ideas.

init method

1. Centos7's grub2 interface will have two entrances, normal system entrance and rescue mode;

2. Modify grub2 boot

Pressing "e" on the normal system entry will enter edit mode and search for the ro line, which starts with linux16;

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

Remove rhgb quiet;(quiet mode does not have code lines swishing away, can be deleted)

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

Press Ctrl+X to start the system.

3. Change the root password

#passwd #change password

#touch /.autorelabel #Selinux is said to update label after reboot

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

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

1. When starting, press "e" on the corresponding startup item and kernel name in the startup interface;

After entering, find the beginning of Linux16, press the "end" key to the end, enter rd.break, press ctrl+x to enter;

3. After entering, enter the command mount, and find that the root is/sysroot/, and cannot be written, only ro=readonly permission;

mount -o mount,rw /sysroot/, mount again, then mount, found that you have r,w permissions;

5. chroot /sysroot/change root;

(1)echo redhat| passwd -stdin root Change the root password to redhat, or enter passwd and modify it interactively;

(2) There is also a cp first, and then modify the/etc/shadow file.

6, touch /.autorelabel This sentence is for selinux to take effect

7. Ctrl+D Exit

8 and then reboot.

Tags: Mode entry password method system input beginning permission environment interface single user different permission one line two code kernel just only name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Apple Xiaomi MySQL vpn