Linux 系统启动原理

  • tatget相当与文件系统的目录,service相当文件

  • socket只做端口的监听,80/tcp,3306/tcp....

复制代码
 #查看依赖
 [root@client ~ 16:33:17]# systemctl list-dependencies graphical.target
 graphical.target
 #查看反向依赖
 [root@client ~ 16:35:02]# systemctl list-dependencies sshd.service --reverse 
 sshd.service
 ● └─multi-user.target
 ●   └─graphical.target
 ​

设置系统当前运行 target

复制代码
 #只显示字符界面
 [root@client ~ 16:35:05]# systemctl isolate multi-user.target
 #恢复到图形化界面
 [root@client ~ 16:36:58]# systemctl isolate graphical.target 

设置系统开机默认运行 target

复制代码
 #执行这些命令后,系统重启会从默认的 图形化界面(graphical.target) 切换到 纯命令行界面(multi-user.target)
 [root@client ~ 16:37:06]# systemctl get-default 
 graphical.target
 ​
 [root@client ~ 16:39:18]# systemctl set-default multi-user.target
 Removed symlink /etc/systemd/system/default.target.
 Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.
 #重启验证

字符界面恢复图形化

复制代码
 vm虚拟机重启按任意键,暂停(除了回车键)
 按e进入编辑
 下方向键,找到initrd16 /.... 到其上一行输入systemd.unit=multi-user.target
 ctrl+x退出恢复图形化

重置 ROOT 密码

复制代码
 vm虚拟机重启按任意键,暂停(除了回车键)
 按e进入编辑
 下方向键,找第二行utf-8,空格把第二行伪代码空格掉再输入rd.break,再ctrl+x执行
 switch_root:/# mount -o remount,rw /sysroot
 switch_root:/# chroot /sysroot
 #设置123密码
 sh-4.4# echo 123 | passwd --stdin root
 #改语言
 unset LANG
 #再设置123密码
 sh-4.4# echo 123 | passwd --stdin root
 ​
 #如果系统开启了 SELinux 功能,则需要确保所有未标记的文件(包括此时的/etc/shadow)在启动过程中都会重新获得标记。
    sh-4.2# touch /.autorelabel     
 ​
 #执行以下命令,系统将继续启动。如果系统开启了SELinux功能,还需要执行完整的 SELinux 重新标记,然后再次重新启动。
    sh-4.2# exit
 #再次退出
 exit
相关推荐
王 富贵12 小时前
【Linux】防火墙常用命令(iptables/firewalld/ufw)
linux·运维·服务器
写代码的【黑咖啡】12 小时前
Linux系统简介及常用命令分类详解
linux·运维·服务器
北极糊的狐12 小时前
报错java: 找不到符号符号: 类 XxxController位置: 程序包 com.ruoyi.xxx.xxx.service
开发语言·windows·python
lang2015092813 小时前
Sentinel限流核心:ThrottlingController设计详解
服务器·网络·sentinel
这儿有一堆花13 小时前
Windows 环境下 Nmap 的实战逻辑
windows·网络安全
YFLICKERH13 小时前
【Linux系统】ubuntu 25.04 虚拟机联网与DNS域名问题排查案例
linux·ubuntu25.04
松涛和鸣13 小时前
DAY27 Linux File IO and Standard IO Explained: From Concepts to Practice
linux·运维·服务器·c语言·嵌入式硬件·ubuntu
GeniuswongAir13 小时前
飞牛NAS死机排查
linux·运维·服务器
hhcgchpspk13 小时前
linux查找并杀死进程部分方法
linux·运维·服务器·网络·经验分享
董世昌4113 小时前
JavaScript 变量声明终极指南:var/let/const 深度解析(2025 版)
java·服务器·前端