systemd commands

26 commands, each with a one-line explanation. Click a command to copy it, or its title for details.

Commands 26 shown

  • systemctl enable --now myapp.service

    Enable at boot and start immediately in one command

  • systemctl list-units --state=failed

    List all units that are in a failed state

    debug

  • systemctl daemon-reload && systemctl restart myapp.service

    Reload unit definitions and restart the service

  • systemctl edit myapp.service

    Create /etc/systemd/system/myapp.service.d/override.conf with partial overrides

  • systemctl cat myapp.service

    Print the full unit file including drop-ins

    debug

  • systemd-analyze blame | head -20

    Show top 20 units by initialization time

    performance · monitoring

  • systemd-analyze dot --require | dot -Tsvg > boot.svg && open boot.svg

    Render full boot dependency graph as SVG

    debug

  • cat > /etc/systemd/system/myapp.service <<EOF [Unit] Description=My App After=network.target [Service] ExecStart=/usr/bin/myapp Restart=always RestartSec=5 User=appuser [Install] WantedBy=multi-user.target EOF

    Minimal systemd service unit template

  • systemd-run --uid=1000 --gid=1000 --wait /usr/bin/myapp --task

    Run a transient one-shot unit under a specific user

  • cat > /etc/systemd/system/backup.timer <<EOF [Unit] Description=Daily backup [Timer] OnCalendar=daily Persistent=true [Install] WantedBy=timers.target EOF

    Replacement for cron with Persistent=true for missed runs

  • systemctl set-property myapp.service MemoryMax=512M CPUQuota=50%

    Apply cgroup limits without editing unit file

    performance

  • systemctl status myapp.service | grep -E 'Memory:|CPU:|Tasks:'

    Current memory, CPU, and task counts from cgroup

    monitoring

  • systemctl list-units --type=socket --all

    All socket-activated units and their state

    network

  • systemctl mask snapd.service

    Prevent a service from being started by anything

    security

  • systemctl show myapp.service -p Environment

    Print environment variables injected into the service

    debug

  • systemd-analyze critical-chain <unit>

    Show the serialized dependency chain that actually delays boot; more honest than blame

    performance · troubleshooting

  • systemd-analyze plot > boot.svg

    Render full parallel boot timeline as an SVG to spot serialized stalls visually

    performance · observability

  • systemctl edit <unit> # writes /etc/systemd/system/<unit>.d/override.conf

    Patch a unit via drop-in without touching the vendor file; use --full to fork the whole unit

    gitops · troubleshooting

  • systemctl daemon-reload

    Reload unit files after editing; note: required after manual edits or systemctl warns of stale config

    troubleshooting

  • systemctl mask <unit> && systemctl unmask <unit>

    Mask symlinks a unit to /dev/null so it cannot start even as a dependency; stronger than disable

    security · troubleshooting

  • systemctl list-dependencies <unit> --all

    Walk the full Wants/Requires tree to debug why a service pulls in others; --reverse for who needs it

    debug · troubleshooting

  • systemctl show -p MainPID,MemoryCurrent,TasksCurrent <unit>

    Read live cgroup metrics straight from systemd without ps; MemoryCurrent is the accounted RSS

    monitoring · performance

  • systemctl reset-failed && systemctl list-units --state=failed

    Reset failed counters so units can restart past StartLimitBurst, then list what is still failed

    troubleshooting · debug

  • systemd-run --on-calendar='*-*-* 03:00:00' --unit=backup /usr/local/bin/backup.sh

    Spin up a throwaway timer+service without writing unit files; great for ad-hoc scheduled jobs

    ci · troubleshooting

  • systemctl set-property --runtime <unit> MemoryMax=512M CPUQuota=50%

    Apply cgroup limits live without restart; --runtime keeps them volatile (gone on reboot)

    performance · troubleshooting

  • systemctl list-jobs

    Show in-flight start/stop jobs to diagnose a hung boot or a unit stuck activating

    debug · troubleshooting