aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/linux/systemd.md
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2022-03-13 16:37:12 +0100
committerJohannes Stoelp <johannes.stoelp@gmail.com>2022-03-13 16:37:12 +0100
commit1be3a8c1400debd5239b23db2686faab3276c59c (patch)
treebd9f509bb2ffbea8a1e9c50b7ff8e3d25faf37c9 /src/linux/systemd.md
parent20590d5c1d973b46b783210e916484aa3b9d3ec9 (diff)
downloadnotes-1be3a8c1400debd5239b23db2686faab3276c59c.tar.gz
notes-1be3a8c1400debd5239b23db2686faab3276c59c.zip
add systemd,core,ptrace_scope
Diffstat (limited to 'src/linux/systemd.md')
-rw-r--r--src/linux/systemd.md68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/linux/systemd.md b/src/linux/systemd.md
new file mode 100644
index 0000000..14ced0b
--- /dev/null
+++ b/src/linux/systemd.md
@@ -0,0 +1,68 @@
+# systemd
+
+## systemctl
+
+Inspect units:
+```text
+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
+
+```bash
+# 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:
+```text
+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:
+```text
+journalctl [opts]
+ --disk-usage Show current disk usage
+ --vacuum-size=<size> Reduce journal log to <size> (K/M/G)
+```
+
+## References
+- [man systemd.unit(5)](https://www.man7.org/linux/man-pages/man5/systemd.unit.5.html)
+- [man systemd.service(5)](https://www.man7.org/linux/man-pages/man5/systemd.service.5.html)