-
-
Notifications
You must be signed in to change notification settings - Fork 2
Arch Linux Systemd Advanced
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to advanced systemd usage on Arch Linux, 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 service
sudo systemctl enable myservice
# Start service
sudo systemctl start myserviceCreate 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: GUI mode
- rescue.target: Rescue mode
- emergency.target: Emergency mode
Switch target:
# Change target
sudo systemctl set-default multi-user.target
# Or
sudo systemctl isolate multi-user.targetCheck logs:
# Service logs
journalctl -u service-name
# Recent logs
journalctl -u service-name -n 50
# Follow logs
journalctl -u service-name -fCheck unit:
# Check unit
systemctl status service-name
# Validate unit file
systemd-analyze verify /etc/systemd/system/service.serviceThis guide covered unit files, creating services, timers, targets, and troubleshooting.
- Systemctl Troubleshooting - More on systemctl
- Arch Linux System Configuration - System setup
- ArchWiki systemd: https://wiki.archlinux.org/title/Systemd
This guide is based on the ArchWiki. For the most up-to-date information, always refer to the official ArchWiki.