daemon
A daemon is simply a background process that runs without direct user interaction. It usually starts at boot and keeps running in the background.
systemd
systemd is the modern init system used by most Linux distributions.
An init system is the first process started by the kernel (PID 1), and it:
- Starts all other services (daemons) and manages them
So:
- daemon = the service itself
- systemd = the manager of services
systemd manages things called units. Common unit types:
servicedaemonssocketnetwork socketstargetgroups of services (like runlevels)
systemctl
systemctl is the command-line tool used to interact with systemd
Start a service:
sudo systemctl start sshd
Stop a service:
sudo systemctl stop sshd
Restart a service, kills the current process and starts a brand-new one:
sudo systemctl restart sshd
Reload a service, sends a signal to the service to re-read its configuration files without dropping connections or stopping the service:
Not all services support reload.
sudo systemctl reload sshd
Check a service status:
systemctl status sshd
Enable service at boot:
systemctl enable sshd
Disable service at boot:
systemctl disable sshd
Where services are defined
Service files live in:
/etc/systemd/system/
/usr/lib/systemd/system/
There are two locations because systemd separates vendor-provided units from administrator-customized units. This is mainly about package management safety and override behavior.
Example service file:
sshd.service
/etc/rc
This comes from older init systems (before systemd), mainly:
- SysVinit
- BSD-style init
rc stands for run commands. It refers to scripts that run during boot.