From bc55732c55a0c854f6e3c3cc40efd603907ecdcb Mon Sep 17 00:00:00 2001 From: johannst Date: Tue, 15 Mar 2022 17:05:22 +0000 Subject: deploy: 33d74c3b33394769a2040ff451fbfdfd58e9bf92 --- linux/systemd.html | 281 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 linux/systemd.html (limited to 'linux/systemd.html') diff --git a/linux/systemd.html b/linux/systemd.html new file mode 100644 index 0000000..f546a87 --- /dev/null +++ b/linux/systemd.html @@ -0,0 +1,281 @@ + + + + + + systemd - Notes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + +
+
+

systemd

+

systemctl

+

Inspect units:

+
systemctl [opts] [cmd]
+[opts]
+    --user
+
+[cmd]
+    list-units <pattern>    List units in memory
+
+    status <unit>           Show runtime status of unit
+
+    start <unit>            Start a unit
+    stop <unit>             Stop a unit
+    restart <unit>          Restart a unit
+    reload <unit>           Reload a unit
+
+    enable <unit>           Enable a unit (persistent)
+    disable <unit>          Disable a unit
+
+    cat <unit>      Print unit file
+    show <unit>     Show properties of unit
+
+

Example: Trivial user unit

+
# Generate unit
+mkdir -p ~/.config/systemd/user
+echo '[Unit]
+Description=Test logger
+
+[Service]
+Type=oneshot
+ExecStart=logger "Hello from test unit"' > ~/.config/systemd/user/test.service
+
+# Run unit
+systemctl --user start test
+
+# See log message
+journalctl --user -u test -n 5
+
+

journalctl

+

Inspect journal logs:

+
journalctl [opts] [matches]
+    --user          Current user journal (system by default)
+    -u <unit>       Show logs for specified <unit>
+    -n <lines>      Show only last <lines>
+    -f              Follow journal
+    -g <pattern>    Grep for <pattern>
+
+

Cleanup:

+
journalctl [opts]
+    --disk-usage            Show current disk usage
+    --vacuum-size=<size>    Reduce journal log to <size> (K/M/G)
+
+

References

+ + +
+ + +
+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3