Skip to content
Log In Sign Up info@muvcloud.com

A Daemon in Plain Words

A daemon is a program that runs in the background without a terminal, started by the system rather than by a person, and usually kept running until shutdown. It waits for work: a network connection, a time on the clock, or a file to appear.

Typical signs of a daemon:

  • No terminal: it is not attached to any login session, so closing your SSH window does not stop it.
  • Started at boot: the init system, systemd, starts it and becomes its parent process.
  • Own user: many daemons run as a dedicated account such as www-data or mysql, not as root.
  • Logs instead of screen output: messages go to the journal or to files under /var/log.

Why Many Names End in d

By old Unix habit, a daemon's program name often ends in the letter d:

DaemonWhat it does
sshdAccepts SSH logins
chronydKeeps the clock in sync
systemd-journaldCollects log messages
containerdRuns containers
crondRuns cron jobs on AlmaLinux and Rocky Linux

The habit is not a rule. Nginx, PostgreSQL, and the cron daemon on Debian and Ubuntu, named cron, are daemons without the d.

Daemon, Process, and Service

  • Process: any running program, including a command you typed a second ago.
  • Daemon: a long-running process in the background, with no terminal.
  • Service: the unit systemd manages for a daemon: how to start it, as which user, and what to do if it stops. The service ssh on Ubuntu runs the daemon sshd.

How systemd Starts and Supervises Them

At boot, systemd reads its unit files and starts every enabled service in the right order. It records each daemon's process ID, collects its output, and can restart it when it exits with an error. You control daemons through systemd rather than by starting them by hand:

systemctl status ssh
sudo systemctl restart nginx
sudo systemctl enable --now cron

On AlmaLinux and Rocky Linux the SSH and cron services are named sshd and crond. To stop a daemon, use systemctl stop; sending a signal directly, as described in how to kill a process in Linux, is for programs that no longer respond. Background on the init system is in what is systemd.

List the Daemons on Your Server

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

This lists every service that is running now. To see the processes themselves, with the terminal each one belongs to:

ps -eo pid,ppid,user,tty,comm

A question mark in the terminal column means the process has no terminal, and a parent process ID (PPID) of 1 means systemd started it directly: both are typical of a daemon. More filters are in how to list services with systemctl and how to list processes in Linux.

Read a Daemon's Logs

sudo journalctl -u nginx -n 50
sudo journalctl -u nginx -f

The first command shows the last 50 lines for one service; the second follows new lines until you press Ctrl+C. Some daemons also keep their own files, such as a web server's access log. See journalctl and Linux log files.

Run Your Own Program as a Daemon

A program of your own, such as an API written in Node.js or Python, becomes a daemon when systemd runs it as a service. The program stays in the foreground and writes to standard output; systemd takes care of the background part, the logs, and restarts. Create /etc/systemd/system/myapp.service:

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

[Service]
User=deploy
WorkingDirectory=/opt/myapp
ExecStart=/opt/myapp/bin/server
Restart=on-failure

[Install]
WantedBy=multi-user.target

Then load and start it:

sudo systemctl daemon-reload
sudo systemctl enable --now myapp
systemctl status myapp

Each line of the file is explained in systemd unit files. Starting a program with nohup also keeps it running after you log out, but nothing restarts it after a crash or a reboot.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations