Systemd is primarily an init system for Linux operating systems. It’s main task is to initialize the components that must be started after the Linux kernel is booted.

An init system start system services, load drivers, bring up network interfaces and more at startup, allowing for the system to reach a usable state.

These components will be called user space (or userland) and refers to all code that runs outside the operating system’s kernel.

To find out what init system your Linux OS is using, you can use one of the following commands

$ cat /proc/1/comm

The following commands will show a symbolic link to the actual init system
$ stat /proc/1/exe
$ stat/sbin/init

The start of these components will also be named to bootstrap user space

In general, bootstrapping usually refers to a self-starting process that is supposed to continue or grow without external input.

init system
In Unix-based computer operating systems, init (short for initialization) is the first process started during booting of the computer system. Init is a daemon process that continues running until the system is shut down. It is the direct or indirect ancestor of all other processes and automatically adopts all orphaned processes. Init is started by the kernel during the booting process; a kernel panic will occur if the kernel is unable to start it. Init is typically assigned process identifier 1.


$ sudo ps -aux

The name systemd adheres to the Unix convention of naming daemons by appending the letter d.

But systemd is not just an init system as mentioned, it is a software suite that provides several system components and tools for Linux operating systems.

We are interested in this post in its capabilities to manage these components (services called daemons in Linux) by using the systemctl command.

The systemctl command is the central management tool to manage the init system. These services resp. daemons are also called units in systemd.

Units will not only for daemons created but also for timer, mount points, sockets, swap storage and devices.

System wide Units (Ubuntu)

  • /lib/systemd/system: all files from units they were pre-installed by the system. You shouldn’t edit these files.
  • /etc/systemd/system: all files from system wide units they were installed or edited by user’s.

In case there where units with the same name in both paths, the units from /etc/systemd/system will be loaded by the kernel. You will also find under /etc/systemd/system units they link to the /lib/systemd/system unit.

You will also see the path of a unit by using the following command to check the status of the service

$ systemctl status servicename.service

User Units (Ubuntu)

systemd user units are nearly the same as system wide units but they will not start automatically at booting the system.

User units wont start until the user they enabled it is logon on to the system interactive or remote per SSH. Per default user units runs with the user account it was enabled.

Below the path for the user units

  • /usr/lib/systemd/user: pre-installed files for user units
  • /etc/systemd/user: units created by the user
  • ~/.local/share/systemd/user: local units just for the user
  • ~/.config/systemd/user: all user units created or edited by the user itself

As mentioned I will focus on managing the service units below. The service units had the .service suffix which you do not need to append for most services and systemd will recognize without.

Show actual Version of Systemd and Systemctl

$ systemd –version
$ systemctl –version

List active Systemd Services

$ systemctl list-units –type service

List all Units loaded or attempted to load

$ systemctl list-unit-files –type=service

Starting and Stopping Services

To start a service (daemon)
$ sudo systemctl start servicename.service
$ sudo systemctl start servicename

$ sudo systemctl start ssh

To stop a service (daemon)
$ sudo systemctl stop servicename.service

Restart and Reloading Services

To restart a service
$ sudo restart servicename.service

To reload a service (just reload its configuration and still provide the service running)
$ sudo reload servicename.service

Enable and Disable Services

To enable the start of a service at boot automatically
$ sudo enable servicename.service

To disable the service will start automatically
$ sudo disable servicename.service

Check the Status of a Service

$ systemctl status servicename.service

You can also check if a service is enabled or disabled by using

$ systemctl is-enabled servicename.service

Further you will also see if a service is enabled or disabled by using the above

$ systemctl status servicename.service

By default apache2 is enabled after installing it, I explicitly disabled it to show the status in the output of this command.

To check if a service is active and running

$ systemctl is-active servicename.service

Show Dependencies

$ systemctl list-dependencies servicename.service

Prevent Services from startet manual with Mask

To prevent a service even if disabled can be started manual, use the following command

$ sudo systemctl mask servicename.service

You can unmask a service in order it can be started manual by
$ sudo systemctl unmask servicename.service

Edit Services

Systemd services can be modified using the following command

$ sudo systemctl edit httpd.service

This creates an override file /etc/systemd/system/httpd.service.d/override.conf and opens it in your text editor. Anything you put into this file will be added to the existing service file.

To completely replace (instead of just add to/modify) an existing service file, use systemctl edit –full, e.g. systemctl edit –full httpd.service. This will create /etc/systemctl/system/httpd.service, which will be used instead of the existing service file.


Manage Run Levels

On Unix-like systems such as Linux, the current state of the OS is known as runlevel. The runlevel determines what services need to be started and running. Under the SysV init system the runlevel are identified by numbers.

In systemd runlevels was replaced with targets.

  • Run level 0 –> 
  • Run level 1  –> 
  • Run level 3 –> 
  • Run level 5 –> 
  • Run level 6  –> 
  • Emergency –>

To change the runlevel resp. now target you can use the following command for example to switch to runlevel 3 –> multi-user.targe

$ sudo systemctl isolate

You can also change the default target which is normally (runlevel 5) as follows

$ sudo systemctl set-default

To list active targets run the following command

$ systemctl list-units –type target


How To Use Systemctl to Manage Systemd Services and Units

User space and kernel space


Systemd on Linux – Manage Services, Run Levels and Logs

How to Change Runlevels (targets) in SystemD

The Story Behind ‘init’ and ‘systemd’: Why ‘init’ Needed to be Replaced with ‘systemd’ in Linux