Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Enter single-user mode under CentOS7

2025-02-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report