Files
DefectingCat.github.io/defect/basic-knowledge-of-systemd.html
DefectingCat 8c7085f18f
2020-11-02 02:17:54 +00:00

62 lines
26 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="zh-CN" data-default-color-scheme="&#34;auto&#34;"><head><meta charset="UTF-8"><link rel="apple-touch-icon" sizes="76x76" href="/images/img/apple-touch-icon.webp"><link rel="icon" type="image/png" href="/images/img/favicon.webp"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,shrink-to-fit=no"><meta http-equiv="x-ua-compatible" content="ie=edge"><meta name="theme-color" content="#9DC8C8"><meta name="description" content=""><meta name="author" content="Defectink"><meta name="keywords" content=""><title>systemd的基础操作 - 🍭Defectink</title><link rel="stylesheet" href="https://cdn.defectink.com/static/twitter-bootstrap/4.5.3/css/bootstrap.min.css"><link rel="stylesheet" href="https://cdn.defectink.com/static/github-markdown-css/4.0.0/github-markdown.min.css"><link rel="stylesheet" href="/lib/hint/hint.min.css"><link rel="stylesheet" href="https://cdn.defectink.com/static/highlight.js/10.0.0/styles/github-gist.min.css"><link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css"><link rel="stylesheet" href="https://cdn.defectink.com/static/t/font_1736178_kmeydafke9r.css"><link rel="stylesheet" href="/css/main.css"><link rel="stylesheet" href="/css/xfy.css"><script src="/js/utils.js"></script><script src="/js/color-schema.js"></script><meta name="generator" content="Hexo 5.2.0"><link rel="alternate" href="/xml/atom.xml" title="🍭Defectink" type="application/atom+xml"><link rel="alternate" href="/xml/rss.xml" title="🍭Defectink" type="application/rss+xml"></head><body><header style="height:75vh"><nav id="navbar" class="navbar fixed-top navbar-expand-lg navbar-dark scrolling-navbar"><div class="container"><a class="navbar-brand" href="/">&nbsp;<strong>🍭Defectink</strong>&nbsp;</a> <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><div class="animated-icon"><span></span><span></span><span></span></div></button><div class="collapse navbar-collapse" id="navbarSupportedContent"><ul class="navbar-nav ml-auto text-center"><li class="nav-item"><a class="nav-link" href="/">🏠 首页</a></li><li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">📕 索引</a><div class="dropdown-menu" aria-labelledby="navbarDropdown"><a class="dropdown-item" href="/categories/">🎁 分类</a> <a class="dropdown-item" href="/tags/">🎐 标签</a></div></li><li class="nav-item"><a class="nav-link" href="/archives/">📂 归档</a></li><li class="nav-item"><a class="nav-link" href="/about/">🎃 关于</a></li><li class="nav-item"><a class="nav-link" href="/links/">🙆‍♀️ 小伙伴</a></li><li class="nav-item"><a class="nav-link" href="/pgp/">🔐 PGP</a></li><li class="nav-item" id="search-btn"><a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;<i class="iconfont icon-search"></i>&nbsp;</a></li><li class="nav-item" id="color-toggle-btn"><a class="nav-link" href="javascript:">&nbsp;<i class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a></li></ul></div></div></nav><div class="banner intro-2" id="background" parallax="true" style="background:url(/images/img/post.webp) no-repeat center center;background-size:cover"><div class="full-bg-img"><div class="mask flex-center" style="background-color:rgba(0,0,0,.3)"><div class="container page-header text-center fade-in-up"><span class="h2" id="subtitle"></span><div class="mt-3"><span class="post-meta mr-2"><i class="iconfont icon-author" aria-hidden="true"></i> Defectink</span><span class="post-meta"><i class="iconfont icon-date-fill" aria-hidden="true"></i> <time datetime="2019-06-14 14:42" pubdate>2019年6月14日 下午</time></span></div><div class="mt-1"><span class="post-meta mr-2"><i class="iconfont icon-chart"></i> 3k 字</span><span class="post-meta mr-2"><i class="iconfont icon-clock-fill"></i> 34 分钟</span></div></div></div></div></div></header><main><div class="container-fluid"><div class="row"><div class="d-none d-lg-block col-lg-2"></div><div class="col-lg-8 nopadding-md"><div class="container nopadding-md" id="board-ctn"><div class="py-5" id="board"><article class="post-content mx-auto" id="post"><h1 style="display:none">systemd的基础操作</h1><p class="note note-info">本文最后水于2020年11月2日 凌晨</p><div class="markdown-body" id="post-body"><h2 id="什么是systemd"><a href="#什么是systemd" class="headerlink" title="什么是systemd"></a>什么是systemd</h2><p>Systemd是我们常用的一些Linux发行版中常见的一套中央化系统及设置管理程序(init),包括有<a target="_blank" rel="noopener" href="https://zh.wikipedia.org/wiki/%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B">守护进程</a><a target="_blank" rel="noopener" href="https://zh.wikipedia.org/wiki/%E7%A8%8B%E5%BC%8F%E5%BA%AB">程序库</a>以及应用软件。</p><p>我们经常使用<code>systemctl start apache2</code>来启动一些服务或者应用软件时使用到的就是Systemd的一部分。</p><p>当前绝大多数的Linux发行版都已采用systemd代替原来的<a target="_blank" rel="noopener" href="https://zh.wikipedia.org/wiki/UNIX_System_V">System V</a></p><h2 id="学习它的作用?"><a href="#学习它的作用?" class="headerlink" title="学习它的作用?"></a>学习它的作用?</h2><p>它能够方便的对一些软件运行进行管理,经常使用<code>systemctl</code>的同学们可能会比较了解,譬如查看运行状态,设置开机自启等操作。</p><p>最近尝鲜了Ubuntu但是遇到个新的问题。在Ubuntu 18.10中,已经将以前的开机自启动的脚本<code>/etc/rc.local</code>去掉了。无意中看到使用systemd来控制开机自启应用程序。</p><p>后来就顺便尝试进一步了解一下systemd毕竟还是比较有用的。</p><h2 id="开机运行启动的原理"><a href="#开机运行启动的原理" class="headerlink" title="开机运行启动的原理"></a>开机运行启动的原理</h2><p>一些支持systemd的软件在安装时会在<code>/usr/lib/systemd/system</code>目录下添加一个支持systemd的配置文件。当我们使用<code>systemctl enable apache2</code>时,就相当于将<code>/usr/lib/systemd/system</code>目录下的配置文件添加一个符号链接,链接到<code>/etc/systemd/system</code>目录。</p><p>当我们的系统开机时systemd会执行<code>/etc/systemd/system</code>目录下的配置文件,以达到开机自启的效果。</p><p>最近发现当前较新的发行版使用enable命令时创建的链接目录为</p><pre><code class="hljs crystal">~ systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/<span class="hljs-class"><span class="hljs-keyword">lib</span>/<span class="hljs-title">systemd</span>/<span class="hljs-title">system</span>/<span class="hljs-title">httpd</span>.<span class="hljs-title">service</span>.</span></code></pre><h2 id="配置文件"><a href="#配置文件" class="headerlink" title="配置文件"></a>配置文件</h2><p>几条常用且熟悉的sysemctl的命令这里就不在详细介绍了。这里直接了解一下最核心的部分配置文件。</p><p>早在很久以前,对于<a href="https://www.defectink.com/defect/12.html">Nyncat</a>这篇文章里面就使用到自己编写systemd的配置文件来达到对nyancat这个服务的详细控制。虽然当时我不理解配置文件说的啥…</p><p>上述了解到,配置文件一般情况下出现在两个地方:<code>/usr/lib/systemd/system</code>目录和<code>/etc/systemd/system/multi-user.target.wants</code>目录。对于完全不了解配置文件的情况下,我们可以先在这两个目录找个案例了解一下。</p><p><strong>某些Ubuntu的发行版可能在<code>/lib/systemd/system</code>目录下保存配置文件</strong></p><p>例如CentOS的httpd</p><pre><code class="hljs routeros">[Unit]
<span class="hljs-attribute">Description</span>=The Apache HTTP Server
<span class="hljs-attribute">After</span>=network.target remote-fs.target nss-lookup.target
<span class="hljs-attribute">Documentation</span>=man:httpd(8)
<span class="hljs-attribute">Documentation</span>=man:apachectl(8)
[Service]
<span class="hljs-attribute">Type</span>=notify
<span class="hljs-attribute">EnvironmentFile</span>=/etc/sysconfig/httpd
<span class="hljs-attribute">ExecStart</span>=/usr/sbin/httpd <span class="hljs-variable">$OPTIONS</span> -DFOREGROUND
<span class="hljs-attribute">ExecReload</span>=/usr/sbin/httpd <span class="hljs-variable">$OPTIONS</span> -k graceful
<span class="hljs-attribute">ExecStop</span>=/bin/kill -WINCH <span class="hljs-variable">$&#123;MAINPID&#125;</span>
<span class="hljs-comment"># We want systemd to give httpd some time to finish gracefully, but still want</span>
<span class="hljs-comment"># it to kill httpd after TimeoutStopSec if something went wrong during the</span>
<span class="hljs-comment"># graceful stop. Normally, Systemd sends SIGTERM signal right after the</span>
<span class="hljs-comment"># ExecStop, which would kill httpd. We are sending useless SIGCONT here to give</span>
<span class="hljs-comment"># httpd time to finish.</span>
<span class="hljs-attribute">KillSignal</span>=SIGCONT
<span class="hljs-attribute">PrivateTmp</span>=<span class="hljs-literal">true</span>
[Install]
<span class="hljs-attribute">WantedBy</span>=multi-user.target</code></pre><p>我们可以了解到,它基本上分为三个区块:<code>Unit</code><code>Service</code><code>Install</code>区块。</p><h3 id="Unit区域"><a href="#Unit区域" class="headerlink" title="Unit区域"></a>Unit区域</h3><p>Unit区域用于解释启动顺序与依赖关系。可以直观的看到它有几个字段</p><ul><li>Description</li><li>After</li><li>Documentation</li></ul><p>第一眼看上去可能都是比较乱七八糟的,根本不知道它在说啥。但是我们拆开来一个一个了解,就会发现它意义非常的简单。</p><p><strong>Description</strong>:用于给出当前服务的简单描述。通常我们查看服务状态时,都会在第一行看到这么一句话:</p><pre><code class="hljs arduino">httpd.service - The Apache HTTP <span class="hljs-built_in">Server</span></code></pre><p>这就是<code>Descipton</code>字段的作用,一句话对当前服务的简单介绍。</p><p><strong>After</strong>:该字段是有关于启动顺序的字段,从字面意思我们就应该大概了解到,这个值应该是定义当前服务应该启动在哪些服务之后。</p><p>上述配置文件该值解释就是:当<code>network.target remote-fs.target nss-lookup.target</code>这些服务需要启动,那么当前的<code>httpd.service</code>应该在他们之后启动。</p><p>相对的,和<code>After</code>对应的还有个<code>Before</code>字段。了解了<code>After</code>这个<code>Before</code>就应该很容易理解了。完全和<code>After</code>相对的意思,定义<code>httpd.service</code>应该在哪些服务之前启动。</p><p>After和Before只关乎到服务的启动顺序并不关乎到依赖关系。</p><p><strong>Documentation</strong>:该字段比较简单,和<code>Descripton</code>作用差不多。它的值用于给出当前服务的文档的位置。</p><p>当前配置文件中并没有说明依赖关系的字段。依赖关系和启动顺序都是写在当前这个Unit区域的它俩非常像象但是作用不同。</p><p>依赖关系有两个字段进行控制:<code>Wants</code><code>Requiers</code></p><p><strong>Wants</strong>:表示弱依赖关系,即使该值内的服务启动失败,也不影响当前服务的继续运行。</p><p><strong>Requires</strong>:表示强依赖关系,如果该值内的服务无法运行,那么当前服务也将停止。</p><p>打个比方:</p><p>当前的httpd.service需要依赖mysql来存储数据。如果在配置文件中它只定义了在mysql之后启动。而没定义依赖关系那么当mysql出现错误停止时在重新启动期间当前的httpd将无法与mysql建立链接。</p><p><strong>这里只是打个比方帮助我们更好的了解实际情况下httpd在通常和mysql是没有这样的依赖关系的🍥。</strong></p><h3 id="Service区域"><a href="#Service区域" class="headerlink" title="Service区域"></a>Service区域</h3><p>Service区域是主要的一部分主要控制软件的启动停止等都是在此部分声明的。也就是定义了如何启动当前的服务。</p><p>许多软件都有环境参数文件,使用<code>EnvironmentFile</code>字段便可以定义环境参数。</p><p><code>EnvironmentFile</code>字段:指定当前服务的环境参数文件。该文件内部的<code>key=value</code>键值对,可以用<code>$key</code>的形式,在当前配置文件中获取。</p><p>例如,启动<code>sshd</code>,执行的命令是<code>/usr/sbin/sshd -D $OPTIONS</code>,其中的变量<code>$OPTIONS</code>就来自<code>EnvironmentFile</code>字段指定的环境参数文件。</p><p>除此之外Service区域还有一些关于控制软件行为的一些字段</p><ul><li><code>ExecStart</code>字段:定义启动进程时执行的命令。</li></ul><ul><li><code>ExecReload</code>字段:重启服务时执行的命令</li><li><code>ExecStop</code>字段:停止服务时执行的命令</li><li><code>ExecStartPre</code>字段:启动服务之前执行的命令</li><li><code>ExecStartPost</code>字段:启动服务之后执行的命令</li><li><code>ExecStopPost</code>字段:停止服务之后执行的命令</li></ul><p>所有的启动设置之前,都可以加上一个连词号(<code>-</code>),表示”抑制错误”,即发生错误的时候,不影响其他命令的执行。比如,<code>EnvironmentFile=-/etc/sysconfig/sshd</code>(注意等号后面的那个连词号),就表示即使<code>/etc/sysconfig/sshd</code>文件不存在,也不会抛出错误。</p><p>此外Service中还有几个比较重要的字段</p><p><strong>Type</strong>字段,它有如下一些值:</p><ul><li>simple默认值<code>ExecStart</code>字段启动的进程为主进程</li><li>forking<code>ExecStart</code>字段将以<code>fork()</code>方式启动,此时父进程将会退出,子进程将成为主进程</li><li>oneshot类似于<code>simple</code>但只执行一次Systemd 会等它执行完,才启动其他服务</li><li>dbus类似于<code>simple</code>,但会等待 D-Bus 信号后启动</li><li>notify类似于<code>simple</code>,启动结束后会发出通知信号,然后 Systemd 再启动其他服务</li><li>idle类似于<code>simple</code>,但是要等到其他任务都执行完,才会启动该服务。一种使用场合是为让该服务的输出,不与其他服务的输出相混合</li></ul><h3 id="Install区域"><a href="#Install区域" class="headerlink" title="Install区域"></a>Install区域</h3><p><code>Install</code>区块,定义如何安装这个配置文件,即怎样做到开机启动。</p><p><code>WantedBy</code>字段:表示该服务所在的 Target。</p><p><code>Target</code>的含义是服务组,表示一组服务。<code>WantedBy=multi-user.target</code>指的是sshd 所在的 Target 是<code>multi-user.target</code></p><p>这个设置非常重要,因为执行<code>systemctl enable sshd.service</code>命令时,<code>sshd.service</code>的一个符号链接,就会放在<code>/etc/systemd/system</code>目录下面的<code>multi-user.target.wants</code>子目录之中。</p><p>Systemd 有默认的启动 Target。</p><pre><code class="hljs bash">$ systemctl get-default
multi-user.target</code></pre><p>一般来说,常用的 Target 有两个:一个是<code>multi-user.target</code>,表示多用户命令行状态;另一个是<code>graphical.target</code>,表示图形用户状态,它依赖于<code>multi-user.target</code>。官方文档有一张非常清晰的 [Target 依赖关系图](<a target="_blank" rel="noopener" href="https://www.freedesktop.org/software/systemd/man/bootup.html#System">https://www.freedesktop.org/software/systemd/man/bootup.html#System</a> Manager Bootup)。</p><p>Target 也有自己的配置文件。</p><pre><code class="hljs bash">$ systemctl cat multi-user.target
[Unit]
Description=Multi-User System
Documentation=man:systemd.special(7)
Requires=basic.target
Conflicts=rescue.service rescue.target
After=basic.target rescue.service rescue.target
AllowIsolate=yes</code></pre><h2 id="详细的字段解释"><a href="#详细的字段解释" class="headerlink" title="详细的字段解释"></a>详细的字段解释</h2><pre><code class="hljs mathematica">[Unit]
Description : 服务的简单描述
Documentation 服务文档
<span class="hljs-keyword">Before</span><span class="hljs-keyword">After</span>:定义启动顺序。<span class="hljs-keyword">Before</span>=xxx.service,代表本服务在xxx.service启动之前启动。<span class="hljs-keyword">After</span>=xxx.service,代表本服务在xxx.service之后启动。
Requires这个单元启动了它需要的单元也会被启动它需要的单元被停止了这个单元也停止了。
Wants推荐使用。这个单元启动了它需要的单元也会被启动它需要的单元被停止了对本单元没有影响。</code></pre><pre><code class="hljs routeros">[Service]
<span class="hljs-attribute">Type</span>=simple默认值systemd认为该服务将立即启动。服务进程不会fork。如果该服务要启动其他服务不要使用此类型启动除非该服务是socket激活型。
<span class="hljs-attribute">Type</span>=forkingsystemd认为当该服务进程fork且父进程退出后服务启动成功。对于常规的守护进程daemon除非你确定此启动方式无法满足需求使用此类型启动即可。使用此启动类型应同时指定 <span class="hljs-attribute">PIDFile</span>=以便systemd能够跟踪服务的主进程。
<span class="hljs-attribute">Type</span>=oneshot这一选项适用于只执行一项任务、随后立即退出的服务。可能需要同时设置 <span class="hljs-attribute">RemainAfterExit</span>=<span class="hljs-literal">yes</span> 使得 systemd 在服务进程退出之后仍然认为服务处于激活状态。
<span class="hljs-attribute">Type</span>=notify<span class="hljs-attribute">Type</span>=simple 相同,但约定服务会在就绪后向 systemd 发送一个信号。这一通知的实现由 libsystemd-daemon.so 提供。
<span class="hljs-attribute">Type</span>=dbus若以此方式启动当指定的 BusName 出现在DBus系统总线上时systemd认为服务就绪。
<span class="hljs-attribute">Type</span>=idle: systemd会等待所有任务(Jobs)处理完成后才开始执行idle类型的单元。除此之外其他行为和<span class="hljs-attribute">Type</span>=simple 类似。
PIDFilepid文件路径
ExecStartPre停止服务时执行的命令
ExecStart指定启动单元的命令或者脚本ExecStartPre和ExecStartPost节指定在ExecStart之前或者之后用户自定义执行的脚本。<span class="hljs-attribute">Type</span>=oneshot允许指定多个希望顺序执行的用户自定义命令。
ExecReload指定单元停止时执行的命令或者脚本。
ExecStop指定单元停止时执行的命令或者脚本。
ExecStopPost停止服务之后执行的命令
ExecStartPost启动服务之后执行的命令
PrivateTmp<span class="hljs-literal">True</span>表示给服务分配独立的临时空间
Restart这个选项如果被允许服务重启的时候进程会退出会通过systemctl命令执行清除并重启的操作。
RemainAfterExit如果设置这个选择为真服务会被认为是在激活状态即使所以的进程已经退出默认的值为假这个选项只有在<span class="hljs-attribute">Type</span>=oneshot时需要被配置。</code></pre><pre><code class="hljs pgsql">[Install]
<span class="hljs-keyword">Alias</span>:为单元提供一个空间分离的附加名字。
RequiredBy单元被允许运行需要的一系列依赖单元RequiredBy列表从Require获得依赖信息。
WantBy单元被允许运行需要的弱依赖性单元Wantby从Want列表获得依赖信息。
<span class="hljs-keyword">Also</span>:指出和单元一起安装或者被协助的单元。
DefaultInstance实例单元的限制这个选项指定如果单元被允许运行默认的实例。</code></pre><h2 id="重启"><a href="#重启" class="headerlink" title="重启"></a>重启</h2><pre><code class="hljs bash"><span class="hljs-comment"># 重新加载配置文件</span>
$ sudo systemctl daemon-reload
<span class="hljs-comment"># 重启相关服务</span>
$ sudo systemctl restart foobar</code></pre></div><hr><div><div class="post-metas mb-3"><div class="post-meta mr-3"><i class="iconfont icon-category"></i> <a class="hover-with-bg" href="/categories/Linux/">Linux</a></div><div class="post-meta"><i class="iconfont icon-tags"></i> <a class="hover-with-bg" href="/tags/Linux/">Linux</a></div></div><p class="note note-warning"><a target="_blank" href="https://zh.wikipedia.org/wiki/Wikipedia:CC_BY-SA_3.0%E5%8D%8F%E8%AE%AE%E6%96%87%E6%9C%AC" rel="nofollow noopener noopener">CC BY-SA 3.0❤</a></p><div class="post-prevnext row"><article class="post-prev col-6"><a href="/defect/try-the-gitlab.html"><i class="iconfont icon-arrowleft"></i> <span class="hidden-mobile">Gitlab尝鲜</span> <span class="visible-mobile">上一篇</span></a></article><article class="post-next col-6"><a href="/defect/public-key-cryptgraphy.html"><span class="hidden-mobile">公开密钥密码学🔑</span> <span class="visible-mobile">下一篇</span><i class="iconfont icon-arrowright"></i></a></article></div></div><article class="comments" id="comments"><div id="vcomments"></div><script type="text/javascript">function loadValine(){addScript("https://cdn.defectink.com/static/valine/1.4.14/Valine.min.js",function(){new Valine({el:"#vcomments",app_id:"dD9t7mcIBVzJWag5ez6GPy2v-MdYXbMMI",app_key:"bWG6pmKsEscrH4JjrpNNAAy6",placeholder:"嘤嘤嘤???",path:window.location.pathname,avatar:"retro",meta:["nick","mail","link"],pageSize:"10",lang:"zh-CN",highlight:!0,recordIP:!1,serverURLs:""})})}waitElementVisible("vcomments",loadValine)</script><noscript>Please enable JavaScript to view the <a target="_blank" href="https://valine.js.org" rel="nofollow noopener noopener">comments powered by Valine.</a></noscript></article></article></div></div></div><div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn"><div id="toc"><p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p><div id="tocbot"></div></div></div></div></div></main><a id="scroll-top-button" href="#" role="button"><i class="iconfont icon-arrowup" aria-hidden="true"></i></a><div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel" aria-hidden="true"><div class="modal-dialog modal-dialog-scrollable modal-lg" role="document"><div class="modal-content"><div class="modal-header text-center"><h4 class="modal-title w-100 font-weight-bold">搜索</h4><button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button></div><div class="modal-body mx-3"><div class="md-form mb-5"><input type="text" id="local-search-input" class="form-control validate"> <label data-error="x" data-success="v" for="local-search-input">关键词</label></div><div class="list-group" id="local-search-result"></div></div></div></div></div><footer class="text-center mt-5 py-3"><div class="footer-content"><a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a><i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a></div><div class="beian"><a href="http://beian.miit.gov.cn/" target="_blank" rel="nofollow noopener">皖ICP备17017808号</a></div></footer><script src="https://cdn.defectink.com/static/jquery/3.4.1/jquery.min.js"></script><script src="https://cdn.defectink.com/static/twitter-bootstrap/4.5.3/js/bootstrap.min.js"></script><script src="/js/debouncer.js"></script><script src="/js/main.js"></script><script src="/js/lazyload.js"></script><script defer="defer" src="https://cdn.defectink.com/static/clipboard.js/2.0.6/clipboard.min.js"></script><script src="/js/clipboard-use.js"></script><script src="/js/xfy.js"></script><script src="https://cdn.defectink.com/static/tocbot/4.11.1/tocbot.min.js"></script><script>$(document).ready(function(){var t=$("#board-ctn").offset().top;tocbot.init({tocSelector:"#tocbot",contentSelector:"#post-body",headingSelector:"h1,h2,h3,h4,h5,h6",linkClass:"tocbot-link",activeLinkClass:"tocbot-active-link",listClass:"tocbot-list",isCollapsedClass:"tocbot-is-collapsed",collapsibleClass:"tocbot-is-collapsible",collapseDepth:3,scrollSmooth:!0,headingsOffset:-t}),0<$(".toc-list-item").length&&$("#toc").css("visibility","visible")})</script><script src="https://cdn.defectink.com/static/typed.js/2.0.11/typed.min.js"></script><script>var typed=new Typed("#subtitle",{strings:[" ","systemd的基础操作&nbsp;"],cursorChar:"❤",typeSpeed:70,loop:!1});typed.stop(),$(document).ready(function(){$(".typed-cursor").addClass("h2"),typed.start()})</script><script src="/js/local-search.js"></script><script>var path="/xml/local-search.xml",inputArea=document.querySelector("#local-search-input");inputArea.onclick=function(){searchFunc(path,"local-search-input","local-search-result"),this.onclick=null}</script><script src="https://cdn.defectink.com/static/fancybox/3.5.7/jquery.fancybox.min.js"></script><link rel="stylesheet" href="https://cdn.defectink.com/static/fancybox/3.5.7/jquery.fancybox.min.css"><script>$("#post img:not(.no-zoom img, img[no-zoom]), img[zoom]").each(function(){var t=document.createElement("a");$(t).attr("data-fancybox","images"),$(t).attr("href",$(this).attr("src")),$(this).wrap(t)})</script><script src="https://cdn.defectink.com/static/mermaid/8.5.0/mermaid.min.js"></script><script>window.mermaid&&mermaid.initialize({theme:"default"})</script></body></html>