Kahibaro
Discord Login Register

System services and daemons

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?

Common examples:

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:

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:

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=service

This shows:

See Only Active Services

To see services that are currently loaded and active:

systemctl list-units --type=service

Useful filters:

  systemctl list-units --type=service --state=running
  systemctl --failed --type=service

These 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:

  sudo systemctl start ssh
  sudo systemctl stop ssh
  sudo systemctl restart ssh
  sudo systemctl reload ssh

Note:

Check Status of a Specific Service

To see whether a service is running and get recent log messages:

systemctl status ssh

Typical fields to look at:

Enabling vs Starting a Service

There are two distinct ideas:

Common commands:

  sudo systemctl enable ssh
  sudo systemctl disable ssh
  sudo systemctl enable --now ssh
  sudo systemctl disable --now ssh

When you install server software (web server, database, SSH, etc.), it might:

Common Everyday Services You May Encounter

As a beginner, you’re likely to interact with a few typical services:

On a new system, it’s useful to get familiar with what is running:

systemctl list-units --type=service --state=running

Take 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:

On systemd systems, you can view more logs with journalctl (covered more deeply later). Basic usage tied to a service:

  sudo journalctl -u ssh
  sudo journalctl -u ssh -f

This 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:

  ps aux

Look for:

Example:

ps aux | grep ssh

You 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:

  sudo service ssh start
  sudo service ssh status

or

  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):

  1. List running services:
   systemctl list-units --type=service --state=running

Pick three services you don’t recognize and briefly search what they do.

  1. Check SSH service (if installed):
   systemctl status ssh

If it’s inactive, try:

   sudo systemctl start ssh
   sudo systemctl enable ssh
  1. Restart a service safely:

Choose a non-critical service (e.g. cron on a test system):

   sudo systemctl restart cron
   systemctl status cron
  1. View logs for a service:
   sudo journalctl -u cron -f

In 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.

Views: 20

Comments

Please login to add a comment.

Don't have an account? Register now!