Systemd

Command demonstrated in this article is tested on RHEL 7 but it can work on CentOS / Fedora / Amazon Linux / Ubuntu and other linux distro as well. This is a first part of series of post that I would be covering entire Systemd and its sub-systems.

Part 1 What is Systemd (Current post)
Part 2 Systemd – Services

Systemd is replacing old “SysV init” as the init system, because of following features

  • Fast parallel boot-up (as it is multithreaded)
  • Socket activation
  • Mount handling
  • Controlling running services

Systemd is a software suite that containing many other bits of functionality and exceed that of an init system, as it goes on to handle power management, device management, mount points, cron, disk encryption, socket API/inetd, syslog, network configuration, login/session management, readahead, GPT partition discovery, container registration, hostname/locale/time management, mDNS/DNS-SD, the Linux console and other things all wrapped into one. It is adopted by many distribution Fedora, OpenSuSE, Arch, RHEL, CentOS, Ubuntu and Debian etc.

Systemd process is the first process ID (PID 1) to run on Linux 7 systems, it initializes the system and launches all the services that were once started by the traditional init(/etc/init.d) process. Systemd process reads the configuration file of /etc/systemd/system/default.target, then its load the OS in targeted runlevel.target.
System startup and server processes are managed by the systemd System and Service Manager. This program provide a method for activating system resources, server daemons, and other processes, both at boot time and on a running system.

Socket is a daemon that listen for connections, and it is a primary communication channel for local or remote clients. Sockets may be created by daemons or may be separated from the daemon and be created by another process, such as systemd. The socket is passed to the daemon when a connection is established by the client.

Systemct1 and Systemd units

Units are systemd objects that are managed by systemct1 command, you can view available unit types using following command.

# systemctl -t help
Available unit types:
service
socket
target
device
mount
automount
snapshot
timer
swap
path
slice
scope

Services units have .service extension and they are used to start accessed daemons, such as a web server, ftp, nfs, samba, kerberos etc.

# systemctl --type=service
UNIT                             LOAD   ACTIVE SUB     DESCRIPTION
abrt-ccpp.service                loaded active exited  Install ABRT coredump hook
abrt-oops.service                loaded active running ABRT kernel log watcher
.......
crond.service                    loaded active running Command Scheduler
.......
krb5kdc.service                  loaded active running Kerberos 5 KDC
.......
ModemManager.service             loaded active running Modem Manager
network.service                  loaded active exited  LSB: Bring up/down networking
.......
slapd.service                    loaded active running OpenLDAP Server Daemon
sshd.service                     loaded active running OpenSSH server daemon
sysstat.service                  loaded active exited  Resets System Activity Logs
.......
vboxadd-service.service          loaded failed failed  vboxadd-service.service
vboxadd-x11.service              loaded active exited  vboxadd-x11.service
vboxadd.service                  loaded failed failed  vboxadd.service

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.

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

Socket units have a .socket extension and it is used for inter-process communication (IPC) sockets. Control of the socket will be passed to a daemon or newly started service when a client connection is made.

# systemctl --type=socket
UNIT                         LOAD   ACTIVE SUB       DESCRIPTION
avahi-daemon.socket          loaded active running   Avahi mDNS/DNS-SD Stack Activation Socket
dbus.socket                  loaded active running   D-Bus System Message Bus Socket
dm-event.socket              loaded active listening Device-mapper event daemon FIFOs
iscsid.socket                loaded active listening Open-iSCSI iscsid Socket
iscsiuio.socket              loaded active listening Open-iSCSI iscsiuio Socket
lvm2-lvmetad.socket          loaded active running   LVM2 metadata daemon socket
rpcbind.socket               loaded active running   RPCbind Server Activation Socket
systemd-initctl.socket       loaded active listening /dev/initctl Compatibility Named Pipe
systemd-journald.socket      loaded active running   Journal Socket
systemd-shutdownd.socket     loaded active listening Delayed Shutdown Socket
systemd-udevd-control.socket loaded active running   udev Control Socket
systemd-udevd-kernel.socket  loaded active running   udev Kernel Socket

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.

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

Path units have a .path extension and are used to delay the activation of a service until a specific file system change occurs. It is commonly used for services which use spool directories, such as printing system.

# systemctl --type=path
UNIT                               LOAD   ACTIVE SUB     DESCRIPTION
brandbot.path                      loaded active waiting Flexible branding
systemd-ask-password-plymouth.path loaded active waiting Forward Password Requests to Plymouth Directory Watch
systemd-ask-password-wall.path     loaded active waiting Forward Password Requests to Wall Directory Watch

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.

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

Target units have a .target extension and are used for grouping and ordering units. They are somewhat of a rough equivalent to runlevels in that at different targets different services, sockets, and other units are started. Target units do not offer any additional functionality on top of the generic functionality provided by units.

# systemctl -t target
UNIT                LOAD   ACTIVE SUB    DESCRIPTION
basic.target        loaded active active Basic System
cryptsetup.target   loaded active active Encrypted Volumes
getty.target        loaded active active Login Prompts
graphical.target    loaded active active Graphical Interface
local-fs-pre.target loaded active active Local File Systems (Pre)
local-fs.target     loaded active active Local File Systems
multi-user.target   loaded active active Multi-User System
network.target      loaded active active Network
nfs.target          loaded active active Network File System Server
paths.target        loaded active active Paths
remote-fs.target    loaded active active Remote File Systems
slices.target       loaded active active Slices
sockets.target      loaded active active Sockets
sound.target        loaded active active Sound Card
swap.target         loaded active active Swap
sysinit.target      loaded active active System Initialization
timers.target       loaded active active Timers

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.

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

Note: (*) graphical.target is equivalent of run-level 5.
            (*) multi-user.target is equivalent of run-level 3.


Further link for your reference
https://www.tecmint.com/systemd-replaces-init-in-linux/
https://linoxide.com/linux-command/systemd-vs-sysvinit-cheatsheet/

Advertisements

One thought on “Systemd

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s