Table of Contents
Understanding Services and Daemons on Linux
On Linux, many background tasks run as daemons or services. In this chapter you’ll learn how to recognize them, see what’s running, and do basic management from the command line using common tools. Details of systemd and systemctl are covered later in the dedicated chapter “Systemd and Service Management”; here we stay at the beginner, everyday-usage level.
What Are Daemons and Services?
- Daemon: A background process that usually:
- has no direct user interface,
- runs without being tied to a terminal,
- often starts at boot and runs continuously.
Common examples:
ssh/sshd– allows remote connectionscron/crond– runs scheduled taskscupsd– printing service
- Service (in everyday Linux usage): a daemon (or group of daemons) that is managed by a service manager (most commonly
systemdon modern distributions). You will often see the term “service” used for things that: - start automatically on boot,
- can be started/stopped/restarted with special commands,
- are defined by a service unit or init script.
In practice, people often use “daemon” and “service” almost interchangeably.
How to Tell If Something Is a Daemon
Typical signs that a process is running as a daemon:
- It runs in the background, not attached to your terminal.
- It’s often started as
rootor a dedicated service user. - Its name ends with
d(tradition, not a rule), for example: sshdsystemdcrondcupsd
From the process list (ps aux or ps -ef), you might see something like:
root 713 0.0 0.2 1069828 5388 ? Ss 10:01 0:00 /usr/sbin/sshd -D
The ? under the TTY column means it’s not attached to a terminal — a typical daemon behavior.
Service Managers: systemd vs Others (High-Level)
Different Linux distributions use different “init” or service manager systems:
- systemd (most modern distros: Ubuntu, Debian, Fedora, Rocky/Alma, Arch, etc.)
- SysV init (older style, still present on some systems)
- OpenRC, runit, and others (used on some non-mainstream or specialized distros)
For a beginner on a mainstream distro, you are almost certainly dealing with systemd. Basic commands to control services with systemctl will work on most modern systems; the advanced details are handled in the Systemd and Service Management chapter.
Listing Installed and Running Services (systemd-based)
On a system running systemd, you can inspect services with systemctl.
See All Services
To list all services that systemd knows about:
systemctl list-unit-files --type=serviceThis shows:
- the service name (like
ssh.service,cron.service), - whether it’s
enabled,disabled, etc.
See Only Active Services
To see services that are currently loaded and active:
systemctl list-units --type=serviceUseful filters:
- Only services that are running:
systemctl list-units --type=service --state=running- Only services that failed:
systemctl --failed --type=serviceThese commands are very helpful for quickly diagnosing what’s up and what’s down.
Basic Service Control (Start/Stop/Restart)
As a regular user, you may need sudo to control most system services.
The general pattern with systemctl:
- Start a service (run it now, without changing boot behavior):
sudo systemctl start ssh- Stop a service (shut it down now):
sudo systemctl stop ssh- Restart a service:
sudo systemctl restart ssh- Reload configuration without full restart (only works if the service supports it):
sudo systemctl reload sshNote:
- You can use either
sshorssh.service—systemctlaccepts both.
Check Status of a Specific Service
To see whether a service is running and get recent log messages:
systemctl status sshTypical fields to look at:
Loaded: shows whether the unit file exists and if it’s enabled/disabled.Active:active (running)means it’s up.inactiveorfailedmeans it isn’t.- The bottom part shows recent log lines (useful for quick debugging).
Enabling vs Starting a Service
There are two distinct ideas:
- Starting: runs the service right now.
- Enabling: configures it to start automatically at boot.
Common commands:
- Enable at boot:
sudo systemctl enable ssh- Disable at boot:
sudo systemctl disable ssh- Start now and enable for future boots (combined):
sudo systemctl enable --now ssh- Stop now and disable for future boots:
sudo systemctl disable --now sshWhen you install server software (web server, database, SSH, etc.), it might:
- automatically enable and start a service,
- or require you to enable/start it manually. Check the package’s documentation or the output of the install command.
Common Everyday Services You May Encounter
As a beginner, you’re likely to interact with a few typical services:
- Networking:
NetworkManager.service– manages network connections on many desktops.systemd-networkd.service– network service on some minimal/server systems.- Remote access:
ssh.serviceorsshd.service– allows remote login.- Scheduling:
cron.serviceorcrond.service– job scheduler.- Printing:
cups.service– printing system.- Time synchronization:
systemd-timesyncd.service,chronyd.service, orntpd.service– keep your clock accurate.
On a new system, it’s useful to get familiar with what is running:
systemctl list-units --type=service --state=runningTake note of names you recognize and search the others as needed.
Checking Logs for a Service (Beginner View)
For quick troubleshooting, combining status and logs is powerful:
systemctl status SERVICEalready shows the most recent few log lines.
On systemd systems, you can view more logs with journalctl (covered more deeply later). Basic usage tied to a service:
- Show logs only for one service:
sudo journalctl -u ssh- Follow logs in real time (like
tail -f):
sudo journalctl -u ssh -fThis is very handy when restarting a service and wanting to see if it starts cleanly.
Recognizing Services in the Process List
Even without systemctl, you can recognize daemons in the process list:
- Show all processes:
ps auxLook for:
- processes owned by
rootor special service users (likewww-data,mysql), - processes with
?in the TTY column, - process names ending with
d.
Example:
ps aux | grep sshYou might see:
root 713 0.0 0.2 1069828 5388 ? Ss 10:01 0:00 /usr/sbin/sshd -D
user1 1024 0.0 0.1 20536 2812 pts/0 S+ 10:05 0:00 grep --color=auto ssh
The first line is the actual daemon (sshd); the last line is your grep command.
Service Management on Non-systemd Systems (Quick Note)
On some distributions that do not use systemd, you may see older-style commands. You do not need to master them now, but you may encounter:
- SysV-style init scripts:
sudo service ssh start
sudo service ssh statusor
sudo /etc/init.d/ssh start
If systemctl doesn’t exist on a machine, try service --status-all or consult that distribution’s documentation.
Practical Exercises
Try these on a system you can experiment with (like a VM):
- List running services:
systemctl list-units --type=service --state=runningPick three services you don’t recognize and briefly search what they do.
- Check SSH service (if installed):
systemctl status sshIf it’s inactive, try:
sudo systemctl start ssh
sudo systemctl enable ssh- Restart a service safely:
Choose a non-critical service (e.g. cron on a test system):
sudo systemctl restart cron
systemctl status cron- View logs for a service:
sudo journalctl -u cron -fIn another terminal, restart the service again and watch the logs update.
These exercises will make you comfortable with the basic, everyday tasks of working with services and daemons from the command line.