Though SystemD will be compared to its predecessor SystemV for a long time , it has much more to offer in terms of System Management. It is a new way how Linux interact with the underline Objects such as hardware , sockets , application processes and many more.
Understand How SystemD works
systemd is a system and service manager for Linux, compatible with SysV and LSB init scripts.
Features
- Contrary to its predecessor SystemD handles processes parallel
- socket and D-Bus activation
traditionally services will be configured to start on boot, but with systemd it is more event driven and you can configure to start when something connects to a specific port or a device get connected , this is called socket and d-bus activation. - Offers on-demand starting of daemons, also keeps track of processes using Linux cgroups
- Supports snapshot and restoring of the system state
- Maintains mount and automount points
- Implements an elaborate transactional dependency-based service control logic.
Concept of Units in SystemD
SystemD manages units, which are representations of system resources and services.
Type of Units in SystemD
- Service
A Service unit is used to manage service, the unit file include instruction to start , stop , restart the service. - Socket A network socket associated with a service.
- Device
Unit file related to Device is used to manage Device , start , stop , auto etc. - Mount Unit manages the Mount points via SystemD
- Automount Unit file mounts the file system on system boot. This feature might replace traditional fstab files in the near future.
- Swap Mounts swap space on the system
- Target Targets are much like Runlevel used previously to manage different services to start and stop at different
- Path
A path for path-based activation. For example, you can start services based on the state of a certain path, such as whether it exists or not. - Timer Timer unit is used similar to Crontab to schedule other units.
- Snapshot
A snapshot of the current systemd state. Usually used to rollback after making temporary changes to systemd. - Slice Restriction of resources through Linux Control Group nodes (cgroups).
- Scope Information from systemd bus interfaces. Usually used to manage external system processes.
systemctl
command
is the primary tool to manage SystemD. It can be used for starting , stopping of services as well as enabling and disabling , this was previously performed with service and chkconfig commands in the previous versions.
Description: | Command |
---|---|
Start the Service | systemctl start foo |
Stop the Service | systemctl stop foo |
Restart the Service | systemctl restart foo |
Status of the Service | systemctl status foo |
Enable Service to start at bootime | systemctl enable foo |
Disable the Service | systemctl disable foo |
Check if service is enabled ? |
systemctl is-enabled foo |
Mask the Service |
systemctl mask foo |
Reload the updated unit file | systemctl daemon-reload |
Show Failed Services | systemctl -failed |
Reset any failed service | systemctl reset-failed |
Show properties of the Unit | systemctl show < service > |
Edit the Service Unit | systemctl edit < service > |
Edit the Full Service Unit | systemctl edit --full < service > |
Run on remote host | systemctl -H < host_name > status network |
Changing System State | |
Reboot host | systemctl reboot |
Poweroff host | systemctl poweroff |
Switch to Emergency mode | systemctl emergency |
Log back to default mode (Multi-User) | systemctl default |
Viewing Log Messages | |
Show all log messages | journalctl |
Show only kernel log messages | journalctl -k |
Show log for specific service | journalctl -u network.service |
Follow messages as they appear | journalctl -f |
Besides services, most systemd commands can work with these unit types: paths,
slices, snapshots, sockets, swaps, targets, and timers