Docs / Linux Basics / Managing Systemd Services

Managing Systemd Services

By Admin · Feb 25, 2026 · Updated Apr 24, 2026 · 32 views · 1 min read

What is Systemd?

Systemd is the init system and service manager for modern Linux distributions. It manages services (daemons), mounts, timers, and the entire boot process.

Essential Commands

# Start/stop/restart a service
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl reload nginx    # Reload config without restart

# Enable/disable at boot
sudo systemctl enable nginx
sudo systemctl disable nginx

# Check status
systemctl status nginx
systemctl is-active nginx
systemctl is-enabled nginx

Listing Services

# All loaded services
systemctl list-units --type=service

# Failed services
systemctl --failed

# All installed service files
systemctl list-unit-files --type=service

Creating a Custom Service

Create /etc/systemd/system/myapp.service:

[Unit]
Description=My Application
After=network.target

[Service]
Type=simple
User=www-data
WorkingDirectory=/var/www/myapp
ExecStart=/usr/bin/node /var/www/myapp/server.js
Restart=always
RestartSec=5
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now myapp

Viewing Logs

# Logs for a specific service
journalctl -u nginx

# Follow logs in real time
journalctl -u nginx -f

# Logs since last boot
journalctl -u nginx -b

# Last 100 lines
journalctl -u nginx -n 100

Was this article helpful?