Systemd Usage Guide on RHEL 7 i | Page Table of Contents Overview ....................................................................................................................................................... 1 Applies To.................................................................................................................................................. 1 Pre-Requisites ........................................................................................................................................... 1 Systemd – Generic Information .................................................................................................................... 1 Version ...................................................................................................................................................... 1 Binaries...................................................................................................................................................... 1 Process System.......................................................................................................................................... 2 Systemd – Units ............................................................................................................................................ 2 Systemd – Boot Process ................................................................................................................................ 3 Analyze systemd – Boot Process ............................................................................................................... 3 Analyze systemd – Each Boot Process ...................................................................................................... 4 Analyze systemd – Critical Chain at Boot .................................................................................................. 5 Analyze systemd – Critical Chain by Service Unit ..................................................................................... 6 Analyze systemd – Critical Chain by Target .............................................................................................. 6 Systemd Units Commands ............................................................................................................................ 7 List Units – Available ................................................................................................................................. 7 List Units – Running .................................................................................................................................. 8 List Units – Failed ...................................................................................................................................... 8 List Units – By Type Service....................................................................................................................... 9 List Units – By Type Mount ....................................................................................................................... 9 List Units – By Type Socket ..................................................................................................................... 10 List Units – By Type Slice ......................................................................................................................... 10 List Units – By Type Swap........................................................................................................................ 11 List Units – By Type Snapshot ................................................................................................................. 11 List Units – By Type Path ......................................................................................................................... 11 List Units – By Type Timer ....................................................................................................................... 12 So What’s systemctl / systemd unit Files.................................................................................................... 12 List Service – All Properties ..................................................................................................................... 13 List Service – Specific Property - CPUShares ........................................................................................... 13 List Service – Specific Property - CanReload ........................................................................................... 14 List Service – Specific Property - Conflicts .............................................................................................. 14
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Systemd Usage Guide on RHEL 7
i | P a g e
Table of Contents Overview ....................................................................................................................................................... 1
Applies To .................................................................................................................................................. 1
Systemd – Generic Information .................................................................................................................... 1
Version ...................................................................................................................................................... 1
Process System.......................................................................................................................................... 2
Systemd – Units ............................................................................................................................................ 2
Systemd – Boot Process ................................................................................................................................ 3
Analyze systemd – Boot Process ............................................................................................................... 3
Analyze systemd – Each Boot Process ...................................................................................................... 4
Analyze systemd – Critical Chain at Boot .................................................................................................. 5
Analyze systemd – Critical Chain by Service Unit ..................................................................................... 6
Analyze systemd – Critical Chain by Target .............................................................................................. 6
Systemd Units Commands ............................................................................................................................ 7
List Units – Available ................................................................................................................................. 7
List Units – Running .................................................................................................................................. 8
List Units – Failed ...................................................................................................................................... 8
List Units – By Type Service ....................................................................................................................... 9
List Units – By Type Mount ....................................................................................................................... 9
List Units – By Type Socket ..................................................................................................................... 10
List Units – By Type Slice ......................................................................................................................... 10
List Units – By Type Swap........................................................................................................................ 11
List Units – By Type Snapshot ................................................................................................................. 11
List Units – By Type Path ......................................................................................................................... 11
List Units – By Type Timer ....................................................................................................................... 12
So What’s systemctl / systemd unit Files .................................................................................................... 12
List Service – All Properties ..................................................................................................................... 13
List Service – Specific Property - CPUShares ........................................................................................... 13
List Service – Specific Property - CanReload ........................................................................................... 14
List Service – Specific Property - Conflicts .............................................................................................. 14
Systemd Usage Guide on RHEL 7
ii | P a g e
Service Dependencies ................................................................................................................................. 14
List Dependencies ................................................................................................................................... 15
List Service Dependencies by Service ..................................................................................................... 16
List Dependencies by Target ................................................................................................................... 16
List Service Dependencies – For Service ................................................................................................. 17
List Service Dependencies – Before ........................................................................................................ 17
List Service Dependencies – After ........................................................................................................... 18
List Service Dependencies – Reverse ...................................................................................................... 18
List Service Dependencies – Target ........................................................................................................ 19
List Service Dependencies – Plot ............................................................................................................ 19
Systemd Usage Guide on RHEL 7
1 | P a g e
Overview
Systemctl is a systemd utility which is responsible for controlling the systemd system and service manager.
Systemd is a collection of system management daemons, utilities and libraries which serves as a
replacement of SystemV init daemon.
Systemd functions as central management and configuration platform for UNIX like system.
Applies To
Tested on RHEL 7, CentOS 7.
Pre-Requisites
None
Systemd – Generic Information
Version
To find the version of systemctl executable, run the command;
systemctl --version
Binaries
To find the binaries of systemctl executable, run the command;
whereis systemctl
Systemd Usage Guide on RHEL 7
2 | P a g e
Process System
To know the process associated with systemd run the command;
ps -eaf | grep [s]ystemd
Systemd – Units
There are different units that are managed by systemd and it accepts following units.
Systemctl Units Purpose
systemd.service Manage System Service; A unit configuration file whose name ends in .service encodes information about a process controlled and supervised by systemd.
systemd.socket Manage sockets for each service; A unit configuration file whose name ends in ".socket" encodes information about an IPC or network socket or a file system FIFO controlled and supervised by systemd, for socket-based activation.
systemd.device Manage devices; A unit configuration file whose name ends in ".device" encodes information about a device unit as exposed in the sysfs/udev device tree.
systemd.mount Manage mount points; A unit configuration file whose name ends in ".mount" encodes information about a file system mount point controlled and supervised by systemd.
systemd.target Manage targets; A unit configuration file whose name ends in ".target" encodes information about a target unit of systemd, which is used for grouping units and as well-known synchronization points during start-up. Target units do not offer any additional functionality on top of the generic functionality provided by units. They exist merely to group units via dependencies (useful as boot targets), and to establish standardized names for synchronization points used in dependencies between units. Among other
Systemd Usage Guide on RHEL 7
3 | P a g e
things, target units are a more flexible replacement for SysV runlevels in the classic SysV init system.
systemd.paths Check the existence of files or directories or create them as needed
systemd.slices Manage resources
systemd.snapshots Takes snapshots of the current state of the system
systemd.sockets Set up sockets to allow communication paths to processes that can remain in place, even if the underlying process needs to restart
systemd.swaps Create and use swap files or swap partitions
Systemd.timer Trigger actions based on a timer
Systemd – Boot Process
systemd is the first process started by the kernel. It replaces the venerable SysVinit program (also
called init) and the newer Upstart init system. systemd coordinates the rest of the boot process and
configures the environment for the user.
systemd improves on other init systems with increased parallelization. It starts the process of loading all
programs it launches immediately, and manages information between interdependent programs as they
load. By dissociating programs and their means of communication, each program is able to load without
waiting for unrelated or even dependent programs to load first.
Analyze systemd – Boot Process
To find out overall boot-up performance time consumption for the boot processes under different
categories, run the command;
systemd-analyze
This information are categorized under different heads such as;
kernel
initrd
userspace
Systemd Usage Guide on RHEL 7
4 | P a g e
Analyze systemd – Each Boot Process
You can also analyze boot-up performance, the time consumed by each task / service during the boot
process. Run the command;
systemd-analyze blame
Systemd Usage Guide on RHEL 7
5 | P a g e
Analyze systemd – Critical Chain at Boot
To analyze the boot-up processes that’s critical for the booting the system in the current target, run the
command;
systemd-analyze critical-chain
Note:
If the list is very long the overall boot process is extended / delay in system boot.
Time after the unit is active or started is printed after the "@" character.
Time the unit takes to start is printed after the "+" character.
Systemd Usage Guide on RHEL 7
6 | P a g e
Analyze systemd – Critical Chain by Service Unit
To analyze the boot-up process for a specific service unit and its critical chain, run the command;
systemd-analyze critical-chain sshd.service
Note:
If the list is very long the overall boot process is extended / delay. In case of the specific service takes
longer time to start, it would impact the overall booting of the server
Time after the unit is active or started is printed after the "@" character.
Time the unit takes to start is printed after the "+" character.
Analyze systemd – Critical Chain by Target
To list the “Critical Chain” for different targets, to know the analysis run the command;