We’ve reached Day 6 of the 30 Days of Linux Challenge, and today’s topic is one that lies at the core of how Linux systems run in the background: service and daemon management using systemd
and systemctl
.
If you've ever wondered how your Linux system starts services automatically at boot, keeps applications like SSH or Apache running, or manages background processes — this is how it works.
📚 Table of Contents
- What Are Daemons and Services?
- What Is systemd?
- Introducing systemctl
- Common systemctl Commands
- Understanding Units in systemd
- Real-World Examples
- Try It Yourself
- Why This Matters
What Are Daemons and Services?
A daemon is a background process that runs continuously or is triggered by specific events. These processes:
- Start during boot
- Run silently in the background
- Manage tasks like networking, logging, scheduling, and remote access
Examples include:
-
sshd
– manages SSH access -
cron
– handles scheduled tasks -
httpd
– the Apache web server -
docker
– container runtime service
In Linux, these are referred to as services, and they’re controlled using a tool called systemctl
.
What Is systemd?
systemd
is the init system used by most modern Linux distributions. It is responsible for:
- Booting the system
- Managing system processes and services
- Handling logging, mounts, timers, and more
It replaced older systems like SysVinit and is now standard in distributions like Ubuntu, CentOS, Fedora, RHEL, and Debian.
At the heart of systemd is systemctl
, the command-line utility we use to interact with it.
Introducing systemctl
The systemctl
tool allows you to:
- Start or stop services manually
- Enable or disable services at boot
- Check the status of active services
- Reload service configuration
- Restart crashed or misbehaving services
It’s one of the most-used tools by Linux administrators.
Common systemctl Commands
Here are some of the most essential commands you'll use:
Check system boot and service status
systemctl statusCheck a specific service
systemctl status sshStart/Stop/Restart a service
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
Enable a service at boot
sudo systemctl enable nginxDisable a service at boot
sudo systemctl disable nginxReload a service’s configuration
sudo systemctl reload nginxCheck if a service is enabled
systemctl is-enabled nginxList all active services
systemctl list-units --type=service
Use sudo where required — most service management tasks need elevated privileges.
Understanding Units in systemd
In systemd, a unit is any resource it can manage. Services are just one type of unit.
Unit Type Description
.service :: A running service or daemon
.socket :: A communication socket
.mount :: A mounted filesystem
.timer :: Scheduled task
.target :: A group of services (e.g., multi-user.target)
Most of the time, you’ll be working with .service units, such as nginx.service, sshd.service, etc.
Real-World Examples
Here’s how you might use systemctl on a live server:
- Restart a web server after updating config:
sudo systemctl restart apache2
Enable the firewall to start automatically:
sudo systemctl enable ufw
- Check the status of Docker:
- sudo systemctl status docker
- Disable an unused service:
- sudo systemctl stop bluetooth
- sudo systemctl disable bluetooth
Disabling unnecessary services can improve boot speed and security.
Try It Yourself
Here are a few safe commands to try:
- sudo systemctl status
- sudo systemctl list-units --type=service
- sudo systemctl start cron
- sudo systemctl stop cron
- sudo systemctl restart cron
- sudo systemctl enable cron
- sudo systemctl disable cron You can replace cron with any installed service on your system.
Why This Matters
- Managing services is a core responsibility in Linux system administration and DevOps.
- With systemctl, you can:
- Keep critical services running reliably
- Automate behavior at boot time
- Troubleshoot crashes or misconfigured services
- Secure the system by disabling unneeded daemons
- Improve system uptime and stability
- Whether you’re working on a web server, deploying containers, or managing cloud infrastructure — understanding systemctl gives you full control over the system's heartbeat.