Managing System Processes (Daemons) In Ubuntu

System processes or Mr. daemons are processes that run in the background on your server, most of the time, they start automatically when your server boots.

An example is the OpenSSH Daemon (sshd) which is the daemon for each incoming connection, it listens to the incoming connection without needing input from the user.

Ubuntu 16.04 and above use systems to manage services, with systems services are known as units. The good thing about systems is that it features lots of great tools for managing the services, an example is systemctl command, which allows users to start, stop, and view the status of units on your server.

We would be using OpenSSH as an example, to check the status of a unit, we would use the status keyword, which shows you information regarding the unit, for example, it shows you whether the unit is active(meaning currently running), enabled (meaning its configured to start at boot time), and a host of others, so, let’s check the status of ssh:

systemctl status ssh


user@server:~$ systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2020-06-17 13:24:59 UTC; 2h 28min ago
  Process: 902 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
 Main PID: 1070 (sshd)
    Tasks: 1 (limit: 2317)
   CGroup: /system.slice/ssh.service
           └─1070 /usr/sbin/sshd -D

Jun 17 13:24:50 systemd[1]: Starting OpenBSD Secure Shell server...
Jun 17 13:24:59 sshd[1070]: Server listening on port 22.
Jun 17 13:24:59 sshd[1070]: Server listening on :: port 22.
Jun 17 13:24:59 systemd[1]: Started OpenBSD Secure Shell server.
Jun 17 13:27:31 sshd[1357]: Accepted publickey for pascal from port 49836 ssh2
Jun 17 13:27:31

You can see how it displays useful information regarding the units, so, in the above output, the name of the ssh unit is actually ssh.service, but it already understood that it is part of the name, so, you don’t need to include that.

If the output is condensed, that it is saving the space on the screen, you can append the -l to the see the full log entries, e.g systemctl status -l ssh

Most services in ubuntu will enable it automatically, which means, it would start by itself if your reboot the system, but other services might not, in the case of ssh example above, you can see the vendor preset is set to enabled, which means the next we start the server, ssh will be loaded automatically.

Starting and Stopping a Unit

To stop unit, you use the stop keyword along side the systemctl command, e.g

sudo systemctl stop ssh

and to start, you chang the keyword to start:

sudo systemctl start ssh

The one I like is the restart keyword, this takes care of the start, and stop, it stop the unit, and automatically start it:

sudo systemctl restart ssh

Another useful keyword is the reload command, this is useful with Apache, apache serves web pages to local or remote users, so, you won’t want to stop it as this would be disconnected from the website you are serving, so, if you’ve added some configuration or a new site, and want to only apply the changes you’ve made with disrupting it from the existing connection, use the reload command:

sudo systemctl reload apache2

If you want to enabled a unit, so, it can start automatically when the server boots, you use the enable keyword, and to disable, you use the disable keyword:

sudo systemctl enable ssh — to enable


sudo systemctl disable ssh — to disable

The systemd also features a host of other powerful features, I’ll write more guide about it in the future.

Comment policy: Respectful and beneficial comments are welcome with full open hands. However, all comments are manually moderated and those that doesn't relate with what the passage is saying or offensive comments would be deleted. Thanks for understanding!

Leave a Reply

Your email address will not be published. Required fields are marked *