zoukankan      html  css  js  c++  java
  • /etc/systemd/system和/lib/systemd/system的区别

    搬运文

    1.1 [/usr]/lib/systemd/system/ (软件包安装的单元)

    The expectation is that /lib/systemd/system is a directory that should only contain systemd unit files which were put there by the package manager (YUM/DNF/RPM/APT/etc).

    1.2 /etc/systemd/system/(系统管理员安装的单元, 优先级更高)

    Files in /etc/systemd/system are manually placed here by the operator of the system for ad-hoc software installations that are not in the form of a package. This would include tarball type software installations or home grown scripts.

    2. 优先级

    systemd的使用大幅提高了系统服务的运行效率, 而unit的文件位置一般主要有三个目录:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Table 1.  Load path when running in system mode (--system).
    ┌────────────────────────┬─────────────────────────────┐
    │Path │ Description │
    ├────────────────────────┼─────────────────────────────┤
    │/etc/systemd/system │ Local configuration │
    ├────────────────────────┼─────────────────────────────┤
    │/run/systemd/system │ Runtime units │
    ├────────────────────────┼─────────────────────────────┤
    │/lib/systemd/system │ Units of installed packages │
    └────────────────────────┴─────────────────────────────┘

    这三个目录的配置文件优先级依次从高到低,如果同一选项三个地方都配置了,优先级高的会覆盖优先级低的。

    系统安装时,默认会将unit文件放在/lib/systemd/system目录。如果我们想要修改系统默认的配置,比如nginx.service,一般有两种方法:

    1. /etc/systemd/system目录下创建nginx.service文件,里面写上我们自己的配置。
    2. /etc/systemd/system下面创建nginx.service.d目录,在这个目录里面新建任何以.conf结尾的文件,然后写入我们自己的配置。推荐这种做法。

    /run/systemd/system这个目录一般是进程在运行时动态创建unit文件的目录,一般很少修改,除非是修改程序运行时的一些参数时,即Session级别的,才在这里做修改。

    参考:https://www.dazhuanlan.com/2020/03/14/5e6cb299378a9/

  • 相关阅读:
    Java中的transient关键字
    【笔记】html的改变(上)
    《开发板 — 实现看门狗》
    《头文件导致Symbol xxx multiply defined重复定义问题分析和解决》
    《APP读取按键值》
    《补充 — Linux内核device结构体分析(转)》
    《设备树LED模板驱动程序》
    《C库 — 字符串和整型数相互转换函数atoi和itoa》
    《Ubuntu — rsync命令》
    《Ubuntu — 2>/dev/null和>/dev/null 2>&1和2>&1>/dev/null的区别》
  • 原文地址:https://www.cnblogs.com/xzlive/p/15180969.html
Copyright © 2011-2022 走看看