systemctl list-units --state=help
List the queued jobs systemctl list-jobs
systemctl list-units --type service --state=active
Get failed systemctl list-units --failed
List services enabled on boot systemctl list-unit-files --state=enabled
Prevent service from starting systemctl mask <name>
cat > /etc/systemd/system/<name>.service << EOF
[Unit]
Description=<Name>
After=network-online.target
[Service]
Environment="PORT=9879"
Environment="HOST=::"
ExecStart=/usr/bin/<pwsh> /opt/<name> -start
Restart=always
[Install]
WantedBy=multi-user.target
EOF
Rebuild service oneshot
cat > /etc/systemd/system/<name>-rebuild.service << EOF
[Unit]
Description=Rebuild on Config Changes
[Service]
Type=oneshot
ExecStart=/usr/bin/<pwsh> --cwd=/opt/<name> -build
EOF
Create systemd path to call service on config file change systemd.path
cat > /etc/systemd/system/<name>-rebuild.path << EOF
[Unit]
Description=Monitor Config for Changes
[Path]
PathChanged=/opt/<name>/conf.xml
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now <name>
systemctl enable --now <name>-rebuild.path
[Unit]
Description=Monitor
After=network-online.target
[Service]
ExecStart=/usr/bin/perl /opt/monitor/main.pl -n <n>
Restart=always
[Install]
WantedBy=multi-user.target
$ chmod 664 /etc/systemd/system/monitor.service
systemctl get-default
systemctl set-default graphical.target
systemctl isolate multi-user.target
systemctl rescue
reports system boot time broken down into how long the kernel took to load before entering userspace and how long the userspace components took to load.
systemd-analyze
See a list displaying service start times
systemd-analyze blame
systemd-analyze security <service_name>
...
[Service]
ExecStart=/usr/sbin/<nprogame> -n
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=2
# Hardening
CapabilityBoundingSet=
LockPersonality=yes
MemoryDenyWriteExecute=yes
NoNewPrivileges=yes
PrivateDevices=yes
PrivateTmp=yes
ProtectClock=yes
ProtectControlGroups=yes
ProtectHome=yes
ProtectKernelLogs=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
ProtectSystem=strict
ReadWritePaths=/var/lib
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
StateDirectory=<progname>
...
/etc/systemd/system
/usr/lib/systemd/system