Notes to Self

Alex Sokolsky's Notes on Computers and Programming

systemctl services

This is about working with services. Other aspects of systemctl.

Show Services

Show the running services:

systemctl list-units --type=service | grep running


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

Show the units which failed to start:

systemctl list-units --state=failed

To list all the service units installed in the file system, not only the loaded:

sudo systemctl list-unit-files --type=service

To list only enabled service units:

systemctl list-unit-files --type=service --state=enabled

Show Service Status

systemctl status _service-name_

View Service Properties

systemctl show _service-name_

To display a single property, use the ā€˜-pā€™ flag with the property name:

systemctl show sshd.service -p ControlGroup


View Service Dependencies

systemctl list-dependencies _service-name_

Show Service Log

Use journalctl:

journalctl --no-pager -u _service-name_

Service Management

Service actions:

Start Service

sudo systemctl start _service_name_

Stop Service

sudo systemctl stop _service_name_

Restart Service

sudo systemctl restart UNIT_NAME.service

Reload Service

You may need to reload the service while making changes to the configuration file, which will bring up new parameters that you added.

sudo systemctl reload UNIT_NAME.service

Enable the Service

To start services automatically at boot, run:

sudo systemctl enable UNIT_NAME.service

This will create a symlink from either /usr/lib/systemd/system/UNIT_NAME.service or /etc/systemd/system/UNIT_NAME.service to the /etc/systemd/system/

You can check that the service is enabled by:

systemctl is-enabled UNIT_NAME.service

Disable the Service

To disable the service at boot, run:

sudo systemctl disable UNIT_NAME.service

This will remove the symlink that has created earlier for the service unit.

systemd unit file

There are three main directories where unit files are stored:

Show the unit file

$ systemctl cat acpid.service
# /lib/systemd/system/acpid.service
Description=ACPI event daemon

ExecStart=/usr/sbin/acpid $OPTIONS


Create the unit file

Create systemd service unit file.

Extending the unit file

To extend the default unit file with additional configuration options:

sudo systemctl edit _service_

This creates an override /etc/systemd/system/_service_.d/override.conf and opens it in your text editor. Add new parameters to the unit file and the new parameters will be added to the existing service file when the file saved.

To apply changes made to the unit:

sudo systemctl daemon-reload

This reloads all unit files and recreates the entire dependency tree. To restart the service alone:

sudo systemctl restart _service_

If you change /lib/systemd/system/<servicename>.service and restart the service via

systemctl restart <servicename>.service

it will not load the new settings unless you do:

systemctl daemon-reload

Overriding the default unit configuration

If you want to keep the changes after updating the package that provides the unit file, edit the full unit file:

sudo systemctl edit --full _service_

This will load the current unit file into the editor. When the file is saved, systemctl will create a file /etc/systemd/system/_service_.service.

Any unit file in /etc/systemd/system will override the corresponding file in /lib/systemd/system.


man systemd-delta. To show all the overrides: