Linux systemd启动流程

article/2025/9/15 7:22:15

以Ubuntu 18.04.2 LTS为例,列出Systemd启动target中涉及单元(Unit).

 default.target (= graphical.target by default)

graphical.targetRequires=multi-user.targetWants=display-manager.serviceConflicts=rescue.service rescue.targetAfter=multi-user.target rescue.service rescue.target display-manager.serviceAllowIsolate=yes# ls -l /etc/systemd/system/display-manager.service
lrwxrwxrwx 1 root root 32 6月   3  2019 /etc/systemd/system/display-manager.service -> /lib/systemd/system/gdm3.service[Unit]After=getty@tty1.serviceAfter=rc-local.service plymouth-start.service systemd-user-sessions.serviceOnFailure=plymouth-quit.service[Service]ExecStartPre=/usr/share/gdm/generate-configExecStart=/usr/sbin/gdm3# ls -l /lib/systemd/system/graphical.target.wants/
lrwxrwxrwx 1 root root 39 6月   3  2019 systemd-update-utmp-runlevel.service -> ../systemd-update-utmp-runlevel.service[Unit]Requisite=systemd-update-utmp.serviceAfter=systemd-update-utmp.serviceAfter=runlevel1.target runlevel2.target runlevel3.target runlevel4.target runlevel5.targetBefore=shutdown.target[Service]ExecStart=/lib/systemd/systemd-update-utmp runlevel# ls -l /etc/systemd/system/graphical.target.wants/
lrwxrwxrwx 1 root root 43 6月   3  2019 accounts-daemon.service -> /lib/systemd/system/accounts-daemon.service
lrwxrwxrwx 1 root root 35 6月   3  2019 udisks2.service -> /lib/systemd/system/udisks2.service

 Multi-user.target

Multi-user.target[Unit]Description=Multi-User SystemDocumentation=man:systemd.special(7)Requires=basic.targetConflicts=rescue.service rescue.targetAfter=basic.target rescue.service rescue.targetAllowIsolate=yes# ls -l /lib/systemd/system/multi-user.target.wants/
lrwxrwxrwx 1 root root 15 6月   3  2019 dbus.service -> ../dbus.service
lrwxrwxrwx 1 root root 15 6月   3  2019 getty.target -> ../getty.target
lrwxrwxrwx 1 root root 24 6月   3  2019 plymouth-quit.service -> ../plymouth-quit.service
lrwxrwxrwx 1 root root 29 6月   3  2019 plymouth-quit-wait.service -> ../plymouth-quit-wait.service
lrwxrwxrwx 1 root root 33 6月   3  2019 systemd-ask-password-wall.path -> ../systemd-ask-password-wall.path
lrwxrwxrwx 1 root root 25 6月   3  2019 systemd-logind.service -> ../systemd-logind.service
lrwxrwxrwx 1 root root 39 6月   3  2019 systemd-update-utmp-runlevel.service -> ../systemd-update-utmp-runlevel.service
lrwxrwxrwx 1 root root 32 6月   3  2019 systemd-user-sessions.service -> ../systemd-user-sessions.service# ls -l /etc/systemd/system/multi-user.target.wants/
lrwxrwxrwx 1 root root 35 6月   3  2019  anacron.service -> /lib/systemd/system/anacron.service
lrwxrwxrwx 1 root root 40 6月   3  2019  avahi-daemon.service -> /lib/systemd/system/avahi-daemon.service
lrwxrwxrwx 1 root root 42 7月  31  2019  binfmt-support.service -> /lib/systemd/system/binfmt-support.service
lrwxrwxrwx 1 root root 41 6月   3  2019  console-setup.service -> /lib/systemd/system/console-setup.service
lrwxrwxrwx 1 root root 38 2月   5  2021  containerd.service -> /lib/systemd/system/containerd.service
lrwxrwxrwx 1 root root 32 6月   3  2019  cron.service -> /lib/systemd/system/cron.service
lrwxrwxrwx 1 root root 40 6月   3  2019  cups-browsed.service -> /lib/systemd/system/cups-browsed.service
lrwxrwxrwx 1 root root 29 6月   3  2019  cups.path -> /lib/systemd/system/cups.path
lrwxrwxrwx 1 root root 37 6月   3  2019  dns-clean.service -> /lib/systemd/system/dns-clean.service
lrwxrwxrwx 1 root root 38 6月   3  2019  irqbalance.service -> /lib/systemd/system/irqbalance.service
lrwxrwxrwx 1 root root 38 6月   3  2019  kerneloops.service -> /lib/systemd/system/kerneloops.service
lrwxrwxrwx 1 root root 40 6月   3  2019  ModemManager.service -> /lib/systemd/system/ModemManager.service
lrwxrwxrwx 1 root root 47 6月   3  2019  networkd-dispatcher.service -> /lib/systemd/system/networkd-dispatcher.service
lrwxrwxrwx 1 root root 38 6月   3  2019  networking.service -> /lib/systemd/system/networking.service
lrwxrwxrwx 1 root root 42 6月   3  2019  NetworkManager.service -> /lib/systemd/system/NetworkManager.service
lrwxrwxrwx 1 root root 36 6月   3  2019  ondemand.service -> /lib/systemd/system/ondemand.service
lrwxrwxrwx 1 root root 36 6月   3  2019  pppd-dns.service -> /lib/systemd/system/pppd-dns.service
lrwxrwxrwx 1 root root 36 6月   3  2019  remote-fs.target -> /lib/systemd/system/remote-fs.target
lrwxrwxrwx 1 root root 33 6月   3  2019  rsync.service -> /lib/systemd/system/rsync.service
lrwxrwxrwx 1 root root 35 6月   3  2019  rsyslog.service -> /lib/systemd/system/rsyslog.service
......
lrwxrwxrwx 1 root root 31 2月   5  2021  ssh.service -> /lib/systemd/system/ssh.service
lrwxrwxrwx 1 root root 44 6月   3  2019  systemd-resolved.service -> /lib/systemd/system/systemd-resolved.service
lrwxrwxrwx 1 root root 36 6月   3  2019  thermald.service -> /lib/systemd/system/thermald.service
lrwxrwxrwx 1 root root 38 2月   5  2021  ubuntu-fan.service -> /lib/systemd/system/ubuntu-fan.service
lrwxrwxrwx 1 root root 31 6月   3  2019  ufw.service -> /lib/systemd/system/ufw.service
lrwxrwxrwx 1 root root 47 6月   3  2019  unattended-upgrades.service -> /lib/systemd/system/unattended-upgrades.service
lrwxrwxrwx 1 root root 42 6月   3  2019  wpa_supplicant.service -> /lib/systemd/system/wpa_supplicant.service

basic.target

basic.target[Unit]Description=Basic SystemDocumentation=man:systemd.special(7)Requires=sysinit.targetWants=sockets.target timers.target paths.target slices.targetAfter=sysinit.target sockets.target paths.target slices.target tmp.mountRequiresMountsFor=/var /var/tmpWants=tmp.mount# ls -l /lib/systemd/system/sockets.target
-rw-r--r-- 1 root root 396 1月  28  2018 /lib/systemd/system/sockets.target	
# ls -l /lib/systemd/system/sockets.target.wants
lrwxrwxrwx 1 root root 14 6月   3  2019 dbus.socket -> ../dbus.socket
lrwxrwxrwx 1 root root 25 6月   3  2019 systemd-initctl.socket -> ../systemd-initctl.socket
lrwxrwxrwx 1 root root 32 6月   3  2019 systemd-journald-audit.socket -> ../systemd-journald-audit.socket
lrwxrwxrwx 1 root root 34 6月   3  2019 systemd-journald-dev-log.socket -> ../systemd-journald-dev-log.socket
lrwxrwxrwx 1 root root 26 6月   3  2019 systemd-journald.socket -> ../systemd-journald.socket
lrwxrwxrwx 1 root root 31 6月   3  2019 systemd-udevd-control.socket -> ../systemd-udevd-control.socket
lrwxrwxrwx 1 root root 30 6月   3  2019 systemd-udevd-kernel.socket -> ../systemd-udevd-kernel.socket
# ls -l /etc/systemd/system/sockets.target.wants/
lrwxrwxrwx 1 root root 32 6月   3  2019 acpid.socket -> /lib/systemd/system/acpid.socket
lrwxrwxrwx 1 root root 41 6月   3  2019 apport-forward.socket -> /lib/systemd/system/apport-forward.socket
lrwxrwxrwx 1 root root 39 6月   3  2019 avahi-daemon.socket -> /lib/systemd/system/avahi-daemon.socket
lrwxrwxrwx 1 root root 31 6月   3  2019 cups.socket -> /lib/systemd/system/cups.socket
lrwxrwxrwx 1 root root 33 2月   5  2021 docker.socket -> /lib/systemd/system/docker.socket
lrwxrwxrwx 1 root root 32 6月   3  2019 snapd.socket -> /lib/systemd/system/snapd.socket
lrwxrwxrwx 1 root root 32 6月   3  2019 uuidd.socket -> /lib/systemd/system/uuidd.socket# ls -l /lib/systemd/system/timers.target
-rw-r--r-- 1 root root 445 1月  28  2018 /lib/systemd/system/timers.target
# ls -l /lib/systemd/system/timers.target.wants
lrwxrwxrwx 1 root root 31 6月   3  2019 systemd-tmpfiles-clean.timer -> ../systemd-tmpfiles-clean.timer
# ls -l /etc/systemd/system/timers.target.wants/
lrwxrwxrwx 1 root root 33 6月   3  2019 anacron.timer -> /lib/systemd/system/anacron.timer
lrwxrwxrwx 1 root root 35 6月   3  2019 apt-daily.timer -> /lib/systemd/system/apt-daily.timer
lrwxrwxrwx 1 root root 43 6月   3  2019 apt-daily-upgrade.timer -> /lib/systemd/system/apt-daily-upgrade.timer
lrwxrwxrwx 1 root root 32 6月   3  2019 fstrim.timer -> /lib/systemd/system/fstrim.timer
lrwxrwxrwx 1 root root 35 6月   3  2019 motd-news.timer -> /lib/systemd/system/motd-news.timer
lrwxrwxrwx 1 root root 43 6月   3  2019 snapd.snap-repair.timer -> /lib/systemd/system/snapd.snap-repair.timer# ls -l /lib/systemd/system/paths.target
-rw-r--r-- 1 root root 394 1月  28  2018 /lib/systemd/system/paths.target
# ls -l /etc/systemd/system/paths.target.wants/
lrwxrwxrwx 1 root root 30 6月   3  2019 acpid.path -> /lib/systemd/system/acpid.path
lrwxrwxrwx 1 root root 42 6月   3  2019 apport-autoreport.path -> /lib/systemd/system/apport-autoreport.path# ls -l /lib/systemd/system/slices.target
-rw-r--r-- 1 root root 449 1月  28  2018 /lib/systemd/system/slices.target

sysinit.target

sysinit.target[Unit]Description=System InitializationDocumentation=man:systemd.special(7)Conflicts=emergency.service emergency.targetWants=local-fs.target swap.targetAfter=local-fs.target swap.target emergency.service emergency.target# ls -l /lib/systemd/system/local-fs.target
-rw-r--r-- 1 root root 547 1月  28  2018 /lib/systemd/system/local-fs.target
# ls -l /lib/systemd/system/local-fs.target.wants/
lrwxrwxrwx 1 root root 29 6月   3  2019 systemd-remount-fs.service -> ../systemd-remount-fs.service# ls -l /lib/systemd/system/swap.target
-rw-r--r-- 1 root root 393 1月  28  2018 /lib/systemd/system/swap.target

local-fs.target

local-fs.target	Conflicts=shutdown.targetAfter=local-fs-pre.targetOnFailure=emergency.targetOnFailureJobMode=replace-irreversibly	# ls /lib/systemd/system/local-fs.target.wants/
lrwxrwxrwx 1 root root 29 6月   3  2019 systemd-remount-fs.service -> ../systemd-remount-fs.servicesystemd-remount-fs.serviceAfter=systemd-fsck-root.serviceBefore=local-fs-pre.target local-fs.target shutdown.targetWants=local-fs-pre.targetConditionPathExists=/etc/fstabExecStart=/lib/systemd/systemd-remount-fssystemd-fsck-root.serviceWants=systemd-fsckd.socketBefore=local-fs.target shutdown.targetAfter=systemd-fsckd.socketExecStart=/lib/systemd/systemd-fsck


http://chatgpt.dhexx.cn/article/ykgrpkHQ.shtml

相关文章

关于 Linux中systemd的一些笔记

写在前面 嗯,准备RHCA,学习整理这部分知识博文内容涉及: systemd简述对于unit的信息的介绍通过systemctl命令控制Service unit的DemoService unit配置文件内容,权值的一些介绍 傍晚时分,你坐在屋檐下,看着天慢慢地黑下…

Linux-Systemd

目录 一、Systemd概述 二、Systemd优势 2.1兼容性 2.2启动速度 2.3systemd 提供按需启动能力 2.4采用 linux 的 cgroups 跟踪和管理进程的生命周期 2.5启动挂载点和自动挂载的管理 2.6实现事务性依赖关系管理 2.7日志服务 2.8 依赖关系 2.9systemd 事务 三、unit(单…

Systemd 简介

一 概述 Linux 服务管理有两种方式service和systemctl。而systemd是Linux系统最新的初始化系统(init),作用是提高系统的启动速度,尽可能启动较少的进程,尽可能更多进程并发启动,systemd对应的进程管理命令就是systemctl。值得一提…

systemd简介

Systemd 是一个专用于 Linux 操作系统的系统与服务管理器,其目的是要取代Unix时代以来一直在使用的init系统。 systemd概述Systemd 是 Linux 系统中最新的初始化系统(init),它主要的设计目标是克服 sysvinit 固有的缺点,提高系统的启动速度。 systemd框架图 根据 Linux 惯…

Systemd 入门及常用命令

目录 Systemdsystemd架构systemd 系统管理管理系统查看启动耗时查看当前主机的信息 Unit 资源查看当前系统的所有 Unit查看系统状态和单个 Unit 的状态 Unit 管理依赖关系Unit 配置文件查看配置文件的内容 Targettarget(Systemd) 与 runlevel&#xff08…

systemd 介绍

转自:https://www.linuxidc.com/Linux/2018-03/151291.htm 从 init 系统说起 Linux 操作系统的启动首先从 BIOS 开始,接下来进入 boot loader,由 bootloader 载入内核,进行内核初始化。内核初始化的最后一步就是启动 PID 为 1 的 …

[2020.1.10]systemd介绍

1 systemd基本概念 systemd:a system daemon,相当于以前的init进程,pid1,systemd是1号进程!!! sbin/init --> /lib/systemd/systemd unit: 一个进程,例如lightdm.service job: 一个动作,启动是个job,关闭是个job。开机启动时,systemd…

systemd教程(三)

下来会通过示例来描述不同Service Type值的应用场景。在此之前,强烈建议先阅读前后台进程父子关系和daemon类进程来搞懂进程之间的关系和Daemon类进程的特性。 systemd service:Typeforking 当使用systemd去管理一个长久运行的服务进程时,最…

dpkg打包笔记

dpkg 安装软件 dpkg -i xxx.deb 查看安装目录 dpkg -L xxx 显示版本 dpkg -l xxx 详细信息 dpkg -s xxx 罗列内容 dpkg -c xxxx 卸载软件 dpkg -r xxxx 构建deb包 dpkg -p

dpkg和apt

文章目录 Ubuntu软件安装Deb包安装Deb包简介dpkg常用命令 apt-get源安装apt-get简介apt工作原理apt相关文件常用的apt命令参数apt-getapt-cache dpkg和apt-get的区别 Ubuntu软件安装 Linux有很多种发行版本,各种发行版本之间安装软件方式和命令不一样,同…

dpkg安装

目录 转载:https://blog.csdn.net/u012300744/article/details/80267225 1.安装 (3)安装 sudo dpkg -i deb文件名 (4)根据经验,通常情况下会报依赖关系的错误,我们可以使用以下的命令修复安…

dpkg制作deb包详解

1 deb包文件结构 deb 软件包里面的结构,它具有DEBIAN和软件具体安装目录(如etc, usr, opt, tmp等)。在DEBIAN目录中至少必须包括control文件,还有可能postinst(postinstallation)、postrm(postremove)、preinst(preinstallation)、…

dpkg命令的用法

dpkg命令的用法 dpkg 是Debian package的简写,为”Debian“ 操作系统 专门开发的套件管理系统,用于软件的安装,更新和移除。 所有源自"Debian"的Linux的发行版都使用 dpkg, 例如"Ubuntu" 阅读目录 安装软件列出与该…

dpkg说明

dpkg与centos中的rpm相似,被用于安装,卸载及查询deb包信息。下面简单介绍基础命令。 已有安装包:test.deb。 安装命令: dpkg -i test.deb 安装test.deb软件包 dpkg -c test.deb #查看test.deb软件包中包含的文件结构 安装后查询命令&#xff…

大数据生态和Spark简介

一、大数据时代 1.第三次信息化浪潮:根据IBM前首席执行官郭士纳的观点,IT领域每隔十五年就会迎来一次重大变革。 2.数据产生方式的变革促成大数据时代的来临: ①存储设备容量不断增加 ②CPU处理能力大幅提升 ③网络带宽不断增加 等等&#…

Spark大数据计算引擎介绍

本文内容参考《Spark与Hadoop大数据分析》[美]文卡特安卡姆 著;《大数据架构详解 从数据获取到深度学习》 朱洁 罗华霖 著。 大数据生态的两个主要部分是Hadoop软件框架和Spark内存级计算引擎。Hadoop包含四个项目:Hadoop common,HDFS&#…

大数据之spark_spark简介

什么是Spark Spark是一种快速、通用、可扩展的大数据分析引擎,2009年诞生于加州大学伯克利分校AMPLab,2010年开源,2013年6月成为Apache孵化项目,2014年2月成为Apache的顶级项目,2014年5月发布spark1.0,201…

开源项目_springboot的答题系统+spark大数据实时分析

一、项目展示 在这里,主要展示大数据图表分析的几个页面。更多精彩由您自己发掘! 图1 饼状图 图2 堆叠图 图3 柱状图 二、项目介绍 本项目分为两个模块,第一个为java语言基于springboot实现的答题模块,另一个为scala语言基于spar…

Spark大数据开发技术简介

Spark大数据开发技术简介 轻量级的内存集群计算平台 文章目录 Spark大数据开发技术简介历史沿革Spark的优点对比Apache Spark堆栈中的不同组件基本原理架构组成部署和体系结构Spark运行模式 页面 历史沿革 Apache Spark是一个围绕速度、易用性和复杂分析构建的大数据处理框架最…

【大数据】【Spark】Spark概述

由于Spark程序的编写最好使用Scala语言,可参照博主以下Scala入门文章 链接:https://blog.csdn.net/treesorshining/article/details/124697102 文章目录 1.Spark概念2.Spark与Hadoop的关系1.从时间节点上来看2.从功能上来看 3.Spark与Hadoop的比较4.Spar…