Daemons in Ubuntu

When we start a program, it creates an instance of it. The running instance is itself a process. And, processes mainly belong to two categories – background and foreground processes. If you would like to know more about background and foreground processes in Ubuntu then follow the link here. There are certain background processes which start when we boot our machine, stay there till we either turn off the machine or we ourselves stop a specific process. Such background processes are nothing but Daemons. In this article, we would cover those background processes or Daemons in Ubuntu.

There are numerous services which are provided by daemons. Few of those are – httpd, systemd, ftpd, nfsd and sshd. Notice here that, all the daemons we mentioned end with character ‘d‘ which shows that these are system daemons. Here, of all the daemons – systemd has a special place. It starts with Process ID – 1 and rest of the processes follow after it. Furthermore, we can even utilize it to start daemons as and when required.

It is generally the shell scripts through which we manage daemons. In subsequent articles, we would cover this aspect as well. For now, these shell scripts can be found in directory – /lib/systemd/

Next, we move on how to manage daemons using systemctl command.

Manage daemons using systemctl command

To start a daemon, we can use start sub-command with systemctl. So, this is what it looks like –

systemctl start <process_name>

We would use stop sub-command to stop a daemon –

systemctl stop <process_name>

But, we would sometimes want to stop and start a daemon. For that, we have restart sub-command –

systemctl restart <process_name>

In addition to, there are times when we just want to reload daemon configuration instead of entirely stopping the daemon. And, then start it. For those cases, use reload sub-command –

systemctl reload <process_name>

Lastly, if you to check the current status of the daemon then –

systemctl status <process_name>

We should check the process if we are making changes to it through status sub-command. For instance, if we stopped a daemon then forgot to start it later then, we can check the status using above command to see what’s wrong.

In conclusion, we have covered Daemons in Ubuntu. These are System user processes which run in background.