Linux 101 : Systemd Overview
Units replace i a way scripts for launching programs and targets are the equivalents of runlevels.
A unit describes a service on the system. The unit has the following components:
- configuration file
Below are some of the unit types in Linux:
- device : device managed by systemd
- mount : mountpoint managed by systemd
- target : refers to different states of the OS depending on the programs launched.
- service : defines how applications are managed by systemd
You use the systemctl command to list the units currently loaded in your Linux system:
Units use a configuration files that tell systemd which programs to start and how to start them.
The configuration files live in the /lib/systemd/system directory.
Below is the ssh service unit configuration file - sshd.service -:
Below is a simple description of same of the parameters that we have seen above:
- Description : a short description of the service.
- ExecStart : command that runs when the service is launched.
- After : describes the program that need to run before sshd
- Wantedby : describes the target level of the system that we need to be on to start sshd.
- Restart : describes when to start the service.
Target units use configuration to tell systemd which service units it needs to start.
For example for the graphical target - starts a system with a graphical interface -:
- After : the targets should be loaded before our target.
- Requires : targets that our target needs to start.
- Conflicts : the targets that conflict with our target.
Systemctl is the tool we use to manage services/targets.
Below are some parameters that we could use with the systemctl command:
- list-units : Displays all the units
- default : to modify to the default target unit
- start unit_name : Starts the named unit
- stop unit_name : Stops the named unit
- reload unit_name : reload the configuration of a unit
- restart unit_name : Causes a unit to shut down and restart
- status unit_name : gives us the status of a unit
- enable unit_name : to make a unit to start at boot time