1. What is systemd
In modern Linux systems, systemd is the most commonly used system and service manager.
Its main function is to initialize and manage system processes, services, hardware, networks and other system resources when the system starts, and provide service dependency management, log management and other functions.
At the same time, systemd also provides some tools to help users manage system services and other system resources more conveniently.
2. How to find systemd in Linux systems
In Linux systems, the existence of systemd can be confirmed by checking process No. 1:
First, check process No. 1 in the system and you will find that it is the system's init process, which is responsible for initializing the system and starting other processes.
In the history of Linux development, different Linux distributions use different initialization systems, but these initialization programs are all run as process 1, so we can check in detail whether our process 1 is provided by systemd.
Check the connection of init:
In modern Linux systems, systemd, as the system initialization system, usually replaces the traditional init. However, the system's init process sometimes still appears as /sbin/init as the startup command, and the soft link points to the actual address.
You can also check directly:
3. Main features of systemd
systemd has many modern features and advantages, making it the preferred manager on most Linux systems today.
(1) Unit mechanism: systemd uses unit configuration files to manage system resources such as services, mount points, devices, etc. It is the basic mechanism for other functions of systemd.
(2) Service dependency management: Under the unit mechanism, through service dependencies, the startup sequence of services can be accurately controlled.
(3) Parallel startup of services: systemd supports starting multiple services in parallel instead of starting them one by one like the traditional init system, which can significantly reduce the system startup time.
(4) Process monitoring and automatic restart: systemd supports monitoring the running status of the process and can automatically restart the service when the service crashes. This provides greater stability to the system.
(5) Resource control: systemd can use the cgroups function of the Linux kernel to control the use of system resources, such as CPU, memory, disk I/O, etc. It can better allocate system resources to prevent a process from occupying too many resources and causing system instability.
(6) Log management: systemd includes a built-in log system journald, which is used to collect system and service logs. The journalctl command can be used to easily view and manage log information, and supports log filtering and searching.
(7) Unified management interface: systemd provides a unified command line tool systemctl for managing system services, starting, stopping, restarting, and other operations.
(8) Target mechanism: systemd uses targets to manage system status. For example, multi-user.target represents multi-user mode, which is equivalent to the traditional run level 3. Through the target mechanism, administrators can flexibly control the operating status of the system.
4. History of systemd
After discussing the characteristics of systemd, we can roughly understand why systemd can stand out among many Linux initialization programs.
In addition to systemd, there are some commonly used initialization programs, such as SysV Init and Upstart.
SysV Init: SysV Init first appeared in the Unix system and later became the standard initialization system for the first generation of Linux systems. However, it was gradually eliminated by the mainstream due to its slow serial startup speed, complex script management, and lack of dependency mechanism.
Upstart: Upstart introduced an event-driven model based on SysV Init and supported concurrent startup. After its appearance, it quickly replaced SysV Init on a large scale. However, it was gradually eliminated by the mainstream due to its failure to compete with systemd and lack of subsequent maintenance.
systemd: Sysmted has become the mainstream manager of the current Linux system because it supports parallel startup and dependency management, integrates logging and resource control functions, and provides unified management tools. It is still widely used today.
5. Current disadvantages of systemd
(1) Difficult to learn: Due to the complexity of systemd functions, users may need more time to learn how to configure and manage systemd services.
(2) Overly complex design: Some users believe that systemd is too large and complex, especially its "integrated" design, which may lead to unnecessary functions and increase the complexity of the system.
(3) Imperfect compatibility with traditional systems: Although most Linux distributions currently use systemd, and systemd has been working to improve compatibility, due to the complex involvement, there may be many compatibility issues when porting older services or traditional init services from Linux to systemd.
So systemd can stand out because in addition to its excellent initialization mechanism, it also provides functions and tools that other initialization systems do not have, and as time goes by, systemd's advantages will become more significant. However, it is still a challenge for users to understand its complexity and its potential disadvantages.