-
-
Notifications
You must be signed in to change notification settings - Fork 1
Linux Systemd Advanced
Mattscreative edited this page Dec 5, 2025
·
3 revisions
Complete beginner-friendly guide to advanced systemd usage on Linux, covering Arch Linux, CachyOS, and other distributions including unit files, timers, targets, and systemd customization.
Unit types:
- service: System services
- timer: Scheduled tasks
- target: System states
- mount: Filesystem mounts
- socket: Network sockets
Unit directories:
# System units
/etc/systemd/system/
# User units
~/.config/systemd/user/
# Runtime units
/run/systemd/system/Create service file:
# Create service
sudo vim /etc/systemd/system/myservice.serviceExample:
[Unit]
Description=My Service
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/mycommand
Restart=always
[Install]
WantedBy=multi-user.targetEnable service:
# Reload systemd
sudo systemctl daemon-reload
# Enable and start service (recommended method)
sudo systemctl enable --now myservice.service
# Alternative method (for learning):
# sudo systemctl enable myservice.service
# sudo systemctl start myservice.serviceCreate timer:
# Create timer
sudo vim /etc/systemd/system/mytimer.timerExample:
[Unit]
Description=My Timer
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.targetEnable timer:
# Enable timer
sudo systemctl enable mytimer.timer
# Start timer
sudo systemctl start mytimer.timer
# Check status
systemctl status mytimer.timerCommon targets:
- multi-user.target: Multi-user mode
- graphical.target: Graphical mode
- rescue.target: Rescue mode
- emergency.target: Emergency mode
Change target:
# Change target
sudo systemctl set-default multi-user.target
# Switch to target
sudo systemctl isolate graphical.targetCheck logs:
# Check service logs
journalctl -u myservice.service
# Check status
systemctl status myservice.serviceCheck syntax:
# Check unit file
systemd-analyze verify /etc/systemd/system/myservice.service
# Reload systemd
sudo systemctl daemon-reloadThis guide covered advanced systemd usage for Arch Linux, CachyOS, and other distributions, including unit files, timers, and targets.
- System Configuration - System setup
- Systemctl Troubleshooting - Service management
- ArchWiki systemd: https://wiki.archlinux.org/title/Systemd
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.