Skip to content
Skills Library
DevOps & cloud · Tool integration

systemd

/systemd

Manage Linux services with systemd: write unit files, run an app on boot, restart it when it crashes, read its logs with journalctl, and schedule jobs with timers instead of cron. Use when a user asks to create a systemd service, run a background process on boot, set up a systemd timer, configure dependencies or auto-restart, or harden a service.

Repository
skills ↗
Licence
Apache-2.0
Last repository change
25.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 25.10.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

Manage Linux services with systemd: write unit files, run an app on boot, restart it when it crashes, read its logs with journalctl, and schedule jobs with timers instead of cron. Use when a user asks to create a systemd service, run a background process on boot, set up a systemd timer, configure dependencies or auto-restart, or harden a service.

Original author description

Manage Linux services with systemd: write unit files, run an app on boot, restart it when it crashes, read its logs with journalctl, and schedule jobs with timers instead of cron. Use when a user asks to create a systemd service, run a background process on boot, set up a systemd timer, configure dependencies or auto-restart, or harden a service.

How it works

  1. Overview
  2. Instructions
  3. Examples
  4. Guidelines
Original SKILL.md headings · 114 lines, 589 words
SKILL.md preview
---
name: systemd
description: >-
  Manage Linux services with systemd: write unit files, run an app on boot,
  restart it when it crashes, read its logs with journalctl, and schedule jobs
  with timers instead of cron. Use when a user asks to create a systemd service,
  run a background process on boot, set up a systemd timer, configure
  dependencies or auto-restart, or harden a service.
license: Apache-2.0
compatibility: 'Linux with systemd 240+ (Ubuntu, Debian, RHEL and Fedora families, Arch); root or sudo for system units'
metadata:
  author: terminal-skills
  version: 1.1.0
  category: devops
  repository: https://github.com/systemd/systemd
  tags: "systemd, linux, services, daemon, process-management"
---

# systemd

## Overview

systemd is the init system and service manager on mainstream Linux distributions. Services, timers, sockets and mounts are described by declarative unit files; systemd starts them in dependency order, restarts them on failure, applies resource limits and sandboxing, and collects their output in the journal. Unit files for your own services live in `/etc/systemd/system/` (system) or `~/.config/systemd/user/` (per-user, managed with `systemctl --user`). Syntax below was checked with `systemd-analyze verify` on systemd 255.

## Instructions

### Step 1: Create a service

```ini
# /etc/systemd/system/orders-api.service
[Unit]
Description=Orders API (Node.js)
After=network-online.target postgresql.service
Wants=network-online.target
Requires=postgresql.service

[Service]
Type=exec
User=deploy
Group=deploy
WorkingDirectory=/opt/orders-api
ExecStart=/usr/bin/node dist/server.js
Restart=on-failure
RestartSec=5
Environment=NODE_ENV=production
EnvironmentFile=/etc/orders-api/env

# Hardening
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
PrivateTmp=true
ReadWritePaths=/opt/orders-api/uploads

# Resource limits
MemoryMax=512M
CPUQuota=80%

[Install]
WantedBy=multi-user.target
```

Notes: `ExecStart` needs an absolute path; `Type=exec` reports failure if the binary cannot start (`Type=simple` does not); use `Type=notify` for programs that signal readiness; `Wants=` is a soft dependency, `Requires=` a hard one; keep secrets in the `EnvironmentFile` (mode 0600, owned by root), not in the unit. `After=` only orders startup, it does not pull the other unit in.

### Step 2: Manage the service

```bash
sudo systemd-analyze verify /etc/systemd/system/orders-api.service   # catch typos first
sudo systemctl daemon-reload                  # after creating or editing any unit file
sudo systemctl enable --now orders-api        # start now and on every boot
systemctl status orders-api                   # state, recent log lines, main PID
sudo systemctl restart orders-api
sudo systemctl edit orders-api                # drop-in override instead of editing the original
journalctl -u orders-api -f                   # follow logs
journalctl -u orders-api --since "1 hour ago" -p err
journalctl -u orders-api -b                   # since the last boot
systemctl --failed                            # every unit that failed
```

### Step 3: Timers (cron replacement)

```ini
# /etc/systemd/system/db-backup.timer
[Unit]
Description=Nightly database backup

[Timer]
OnCalendar=*-*-* 03:00:00
RandomizedDelaySec=10min
Persistent=true

[Install]
WantedBy=timers.target
```

```ini
# /etc/systemd/system/db-backup.service  (same base name, started by the timer)
[Unit]
Description=Database backup

[Service]
Type=oneshot
User=deploy
ExecStart=/opt/scripts/backup.sh
```

```bash
systemd-analyze calendar "Mon..Fri *-*-* 03:00"   # check when an expression fires
sudo systemctl enable --now db-backup.timer        # enable the timer, not the service
systemctl list-timers --all
```

## Examples

**Example 1: "Run my Node app on boot and restart it if it crashes"**

Create `orders-api.service` as in Step 1, then `sudo systemctl daemon-reload && sudo systemctl enable --now orders-api`. Result: `systemctl status orders-api` shows `active (running)`; `sudo kill -9 $(systemctl show -p MainPID --value orders-api)` makes it come back after 5 seconds.

**Example 2: "Replace my nightly cron backup"**

Create `db-backup.service` and `db-backup.timer` from Step 3 and enable the timer. Result: `systemctl list-timers` shows the next run at 03:00 plus up to 10 minutes of random delay; a missed run (machine off) executes at next boot because of `Persistent=true`; output is in `journalctl -u db-backup`.

## Guidelines

- Run `daemon-reload` after every unit file change; `systemctl status` warns when the file changed on disk.
- Prefer `Restart=on-failure` for services that may exit cleanly on purpose; `Restart=always` also restarts after a normal stop request from the app. After too many fast failures systemd stops retrying (`StartLimitBurst`, `StartLimitIntervalSec`); fix the crash, then `systemctl reset-failed`.
- Run services as an unprivileged user (`User=` or `DynamicUser=yes`) and add sandboxing; `systemd-analyze security orders-api` scores the unit and lists what to tighten. `ProtectSystem=strict` makes the filesystem read-only except `ReadWritePaths=`.
- Change vendor units with `systemctl edit` drop-ins, never by editing files under `/usr/lib/systemd/system`.
- Logs go to stdout/stderr and the journal; the journal can be volatile unless `/var/log/journal` exists or `Storage=persistent` is set in `journald.conf`.
- Times in `OnCalendar` use the system timezone; use `systemd-analyze calendar` to test.
Files in this package (2)
  • SKILL.md 5 KB
  • _scores.json 3 KB

Versions

RepositoryScoreLicence
This page · TerminalSkills/skills100Apache-2.0
claude-dev-suite/claude-dev-suite100MIT

Database snapshot: 13.11.2026 · package version e5a6364299d6 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 95systemd-cheatsheet
    Use when the user needs systemd commands: systemctl start, stop, enable and status, writing unit files, journalctl log queries, timers instead of cron, boot targets, and diagnosing services that fail to start.
  • 100systemd-services
    Create and manage systemd services and timers. Configure service dependencies and resource limits. Use when managing system services.
  • 100systemd-services
    Create and manage systemd services and timers. Configure service dependencies and resource limits. Use when managing system services.
  • 100systemd-services
    Create and manage systemd services and timers. Configure service dependencies and resource limits. Use when managing system services.
  • 100linux-systemd-service-management
    Use this skill when authoring, sandboxing, and administering background daemon services using systemd unit files.
  • 100linux-log-analysis-journalctl-syslog
    Use this skill when investigating system failures, filtering systemd-journalctl logs by service/priority, and auditing syslog.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.