Linux Services

Linux Services

2023-09-04. Category & Tags: Linux Services, Nix Services

Folders #

Folder Description
/etc/systemd/system/ [suggested] for admin/root user (local config)
/usr/lib/systemd/(system/) for repo installed packages (using e.g. RPM)
/lib/systemd/(system/) (/lib is a symlink to /usr/lib)
/run/systemd/system runtime units

Note: “runtime units”: the ability to make modifications to a process (unit) during the current boot without that change/modification persisting across a reboot.

Tip: check which package a file belongs to:

  • for RPM (Cent/Fedora/RHEL): rpm -qf /usr/lib/systemd/system/* |sort -u | head
  • for Debian/Ubuntu: dpkg -S /lib/systemd/system/* |sort -u | head
    • -S == --search
    • This command will not list extra files created by maintainer scripts, nor will it list alternatives.
    • or: dpkg-query -S ...

Ref’s: man systemd.unit, man 7 file-hierarchy, stackoverflow.

Filenames #

<unit>[@<instance>].<type> [email protected] [email protected] [email protected]

ref: https://unix.stackexchange.com/questions/588629/why-do-some-unit-filenames-end-with

Content #

[Unit]
Description=some description %i.
After=network.target

[Service]
Type=simple
User=%i
Restart=on-abort
ExecStart=/abs/path/to/executable/binary/or/script.sh

[Install]
WantedBy=multi-user.target

Commands #

systemctl daemon-reload
systemctl start clash
systemctl enable clash@$USER