[How To] Configure a Linux Service Startup

Service in the Unix family operating systems is a program that runs in the background and has no windows or other means of communication with the user. In this article we will not consider the features of the structure and launch of services, who are interested, you can find out in Wikipedia. We will use Ubuntu 19.04 for examples.

Ubuntu service startup is controlled by the systemd initialization system.

A list of all services and their status can be viewed using the systemctl utility. To do this, type:

systemctl list-units --type=service
UNIT                               LOAD   ACTIVE SUB     DESCRIPTION
accounts-daemon.service            loaded active running Accounts Service
acpid.service                      loaded active running ACPI event daemon
apparmor.service                   loaded active exited  Load AppArmor profiles
apport.service                     loaded active exited  LSB: automatic crash report generation
avahi-daemon.service               loaded active running Avahi mDNS/DNS-SD Stack
bolt.service                       loaded active running Thunderbolt system service
colord.service                     loaded active running Manage, Install and Generate Color Profiles
console-setup.service              loaded active exited  Set console font and keymap
cron.service                       loaded active running Regular background program processing daemon
cups-browsed.service               loaded active running Make remote CUPS printers available locally
cups.service                       loaded active running CUPS Scheduler
dbus.service                       loaded active running D-Bus System Message Bus
fwupd.service                      loaded active running Firmware update daemon
gdm.service                        loaded active running GNOME Display Manager
grub-common.service                loaded active exited  LSB: Record successful boot for GRUB
ifupdown-pre.service               loaded active exited  Helper to synchronize boot up for ifupdown
irqbalance.service                 loaded active running irqbalance daemon
kerneloops.service                 loaded active running Tool to automatically collect and submit kernel crash signatures
keyboard-setup.service             loaded active exited  Set the console keyboard layout
kmod-static-nodes.service          loaded active exited  Create list of required static device nodes for the current kernel
ModemManager.service               loaded active running Modem Manager
networkd-dispatcher.service        loaded active running Dispatcher daemon for systemd-networkd
networking.service                 loaded active exited  Raise network interfaces
NetworkManager-wait-online.service loaded active exited  Network Manager Wait Online
NetworkManager.service             loaded active running Network Manager
open-vm-tools.service              loaded active running Service for virtual machines hosted on VMware
openvpn.service                    loaded active exited  OpenVPN service
polkit.service                     loaded active running Authorization Manager
....

To get the list of services that are currently running, type the following in the terminal:

systemctl list-units --type=service --state=running
UNIT                        LOAD   ACTIVE SUB     DESCRIPTION
accounts-daemon.service     loaded active running Accounts Service
acpid.service               loaded active running ACPI event daemon
avahi-daemon.service        loaded active running Avahi mDNS/DNS-SD Stack
bolt.service                loaded active running Thunderbolt system service
colord.service              loaded active running Manage, Install and Generate Color Profiles
cron.service                loaded active running Regular background program processing daemon
cups-browsed.service        loaded active running Make remote CUPS printers available locally
cups.service                loaded active running CUPS Scheduler
dbus.service                loaded active running D-Bus System Message Bus
fwupd.service               loaded active running Firmware update daemon
gdm.service                 loaded active running GNOME Display Manager
irqbalance.service          loaded active running irqbalance daemon
kerneloops.service          loaded active running Tool to automatically collect and submit kernel crash signatures
ModemManager.service        loaded active running Modem Manager
networkd-dispatcher.service loaded active running Dispatcher daemon for systemd-networkd
NetworkManager.service      loaded active running Network Manager
open-vm-tools.service       loaded active running Service for virtual machines hosted on VMware
polkit.service              loaded active running Authorization Manager
rsyslog.service             loaded active running System Logging Service
rtkit-daemon.service        loaded active running RealtimeKit Scheduling Policy Service
snapd.service               loaded active running Snappy daemon
ssh.service                 loaded active running OpenBSD Secure Shell server
systemd-journald.service    loaded active running Journal Service
systemd-logind.service      loaded active running Login Service
systemd-resolved.service    loaded active running Network Name Resolution
systemd-timesyncd.service   loaded active running Network Time Synchronization
systemd-udevd.service       loaded active running udev Kernel Device Manager
udisks2.service             loaded active running Disk Manager
unattended-upgrades.service loaded active running Unattended Upgrades Shutdown
upower.service              loaded active running Daemon for power management
[email protected]           loaded active running User Manager for UID 1000
vgauth.service              loaded active running Authentication service for virtual machines hosted on VMware
whoopsie.service            loaded active running crash report submission daemon
wpa_supplicant.service      loaded active running WPA supplicant

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

34 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

[adinserter block=”6″]

Similarly, you can see the services that have already been added to startup:

systemctl list-unit-files --type=service --state=enabled   
UNIT FILE                                  STATE
accounts-daemon.service                    enabled
anacron.service                            enabled
apparmor.service                           enabled
[email protected]                            enabled
avahi-daemon.service                       enabled
bluetooth.service                          enabled
console-setup.service                      enabled
cron.service                               enabled
cups-browsed.service                       enabled
cups.service                               enabled
dbus-fi.w1.wpa_supplicant1.service         enabled
dbus-org.bluez.service                     enabled
dbus-org.freedesktop.Avahi.service         enabled
dbus-org.freedesktop.ModemManager1.service enabled
dbus-org.freedesktop.nm-dispatcher.service enabled
dbus-org.freedesktop.resolve1.service      enabled
dbus-org.freedesktop.thermald.service      enabled
dbus-org.freedesktop.timesync1.service     enabled
dmesg.service                              enabled
dns-clean.service                          enabled
[email protected]                             enabled
gpu-manager.service                        enabled
grub-initrd-fallback.service               enabled
irqbalance.service                         enabled
kerneloops.service                         enabled
keyboard-setup.service                     enabled
ModemManager.service                       enabled
network-manager.service                    enabled
networkd-dispatcher.service                enabled
networking.service                         enabled
NetworkManager-dispatcher.service          enabled
NetworkManager-wait-online.service         enabled
NetworkManager.service                     enabled
ondemand.service                           enabled
open-vm-tools.service                      enabled
openvpn.service                            enabled
pppd-dns.service                           enabled
rsync.service                              enabled
rsyslog.service                            enabled
setvtrgb.service                           enabled
snapd.autoimport.service                   enabled
snapd.core-fixup.service                   enabled
snapd.seeded.service                       enabled
snapd.service                              enabled
snapd.system-shutdown.service              enabled
ssh.service                                enabled
sshd.service                               enabled
switcheroo-control.service                 enabled
syslog.service                             enabled
systemd-resolved.service                   enabled
systemd-timesyncd.service                  enabled
thermald.service                           enabled
udisks2.service                            enabled
ufw.service                                enabled
unattended-upgrades.service                enabled
vgauth.service                             enabled
whoopsie.service                           enabled
wpa_supplicant.service                     enabled

58 unit files listed.

To add a service to autoload use use the enable option:

sudo systemctl enable name_of_service

We can remove a service from startup by using the disable option:

sudo systemctl disable name_of_service

The system will ask for a superuser password and these actions will be performed as superuser.

Test Environment

Ubuntu 20.04 LTS (Focal Fossa)

VMware Workstation 15.1.0

Source

losst.ru

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.