At Boot




Systemd Tools

How to validate systemd service file
Check or lint a service for syntax errors!
	sudo systemd-analyze verify foobar.service




List Running Services
In order to visualize the running services in our system, we can execute the following command: $ systemctl --type=service
Which gives us (cut off for just diaplaying purpose): UNIT LOAD ACTIVE SUB DESCRIPTION alsa-restore.service loaded active exited Save/Restore Sound Card State bolt.service loaded active running Thunderbolt system service dbus.service loaded active running D-Bus System Message Bus iio-sensor-proxy.service loaded active running IIO Sensor Proxy service NetworkManager.service loaded active running Network Manager sddm.service loaded active running Simple Desktop Display Manager systemd-journald.service loaded active running Journal Service systemd-logind.service loaded active running User Login Management user@1000.service loaded active running User Manager for UID 1000 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. 36 loaded units listed. Pass --all to see loaded but inactive units, too. We also get a piece of help if we want to see the installed ones: $ systemctl list-unit-files
Editing service configuration Individually, per service, we can edit its configuration. In this example we are using NetworkManager.service which is one of the main ones for handling our network connection. So let’s see its configuration: $ sudo systemctl edit --full NetworkManager.service And the output: [Unit] Description=Network Manager Documentation=man:NetworkManager(8) Wants=network.target After=network-pre.target dbus.service Before=network.target [Service] Type=dbus BusName=org.freedesktop.NetworkManager #ExecReload=/bin/kill -HUP $MAINPID ExecStart=/usr/bin/NetworkManager --no-daemon Restart=on-failure # NM doesn't want systemd to kill its children for it KillMode=process ProtectSystem=true ProtectHome=read-only # We require file descriptors for DHCP etc. When activating many interfaces, # the default limit of 1024 is easily reached. LimitNOFILE=65536 [Install] WantedBy=multi-user.target Also=NetworkManager-dispatcher.service # We want to enable NetworkManager-wait-online.service whenever this service # is enabled. NetworkManager-wait-online.service has # WantedBy=network-online.target, so enabling it only has an effect if # network-online.target itself is enabled or pulled in by some other unit. Also=NetworkManager-wait-online.service
#Enabling Services After modifying a service file, execute: sudo systemctl daemon-reload # Informs daemong services have changed sudo systemctl start xyz.service # Start new (or reconfigged) service
Tracing It turns out that systemd services have a list of permitted system calls. If a service attempts a system call that isn't permitted, the process is terminated with a SIGSYS signal. To tell systemd to allow the process to execute any system call, you need to update the .service file and add the following under the [Service] section: SystemCallFilter=@known Then, just do a systemctl daemon-reload followed by systemctl start pulseaudio.service (omit --user for system services) and it should start right up. For more information on the SystemCallFilter parameter, refer to man 5 systemd.exec.