Who's Boss
Both init and systemd can be used to start, monitor, and shut down services on Linux systems, but these utilities differ in terms of configuration and operation.
|
Both init and systemd can be used to start, monitor, and shut down services on Linux systems, but these utilities differ in terms of configuration and operation.
When it comes to managing system services, a Linux system administrator can choose between the classic init [1] and the relatively new systemd [2]. These utilities form a meeting ground for mature technology and new concepts.
Directly after booting the kernel, a service will start and then accompany the rest of the system's ongoing operation and shut down. Throughout, this service is assigned the Process ID 1.
You can use ps on a running system to determine which program executes the administration of services. (See the instructions in the "Determining Process 1" box.)Whatever the result, you may be misled because of a possibly existing downward-compatible invocation, which may have convinced you that init is performing this task when it is indeed systemd.
Determining Process 1
Using the correct query, you can determine whether the system uses the classic init or systemd. By means of the -ax option of the ps command, you will get the following output even on a computer managed by systemd.
~$ ps -ax | head -2 PID TTY STAT TIME COMMAND 1 ? Ss 0:01 /sbin/init
To avoid being misled, you should use the -e option so that you get the correct results:
~$ ps -e | head -2 PID TTY TIME CMD 1 ? 00:00:01 systemd
On a system using init, you will get the following output:
~$ ps -e | head -2 PID TTY TIME CMD 1 ? 00:00:00 init
Using pstree also gives you the correct output.
On Linux and other related systems, a runlevel defines a certain system state, which may include services that are running (daemons).
In Table 1, you will find a list of the possible system states. Except for S , all of the other states are indicated with a numerical value running from 0 to 6. The runlevels between 2 and 5 are not used uniformly by the various distributions.
Table 1
Runlevel
Action | Runlevel | Command |
---|---|---|
Shutdown, powering down, writing buffered data to the disk, terminating network connections, synchronization and unmounting the data storage devices from the directory tree (sync, umount), possibly disconnecting the power supply | 0 | shutdown -h now , init 0 |
Single user for root , no network access, computer access only via the console, used for system administration | S | init s |
Single user without network access, computer access only via the console | 1 | init 1 |
Multi-user operation with or without network access, with or without graphical user interface, depends on settings of the distribution used | 2-5 | init [2-5] , exit in s or 1 |
Reboot, reload computer, restart, write buffered data to the disks, disconnect network connections, synchronize, and unmount data storage devices from the directory tree (sync, umount), restart computer with appropriate boot procedure | 6 | shutdown -r now , reboot , init 6 |
You can determine what the default runlevel at system start is by looking at the beginning of the /etc/inittab file. Listing 1 shows a relevant snippet. The standard runlevel of the system, initdefault , is indicated in the line beginning with id . The default runlevel is 2 in the example.
Listing 1
Default runlevel in inittab
01 . 02 . 03 . 04 # The default runlevel. 05 id:2:initdefault: 06 07 # Boot-time system configuration/initialization script. 08 # This is run first except when booting in emergency (-b) mode. 09 si::sysinit:/etc/init.d/rcS 10 11 # What to do in single-user mode. 12 ~~:S:wait:/sbin/sulogin 13 . 14 . 15 .
The single user mode (si: ) must have previously finished, except in emergency mode due to interruptions of the boot process. There's an important entry at the end of the listing. init executes an automatic login for root as a necessary precondition for operating the system in single user mode.
Pages: 1
Some Linux followers see systemd as the best thing since sliced bread – for others, it's the work of the devil. However, it also has the stuff to clear out old trenches and form a unified base for Linux.
Testers constantly encounter new trends in the experimental branches of Linux distributions. I look at who drives Linux forward and how the future is shaping up.
Originally created for use in Ubuntu, Upstart is suitable for deployment in all Linux distributions as an alternative to the System-V init.
Leading ownCloud developers, including the project founder Frank Karlitschek, became dissatisfied with the direction of the project, so they started Nextcloud, a fork of the code and a new company. The goal is to create a better balance among the company, clients, and users. We take a look at how Nextcloud is faring.
Bedrock transparently combines virtually any number of distributions with different architectures, package management, and init systems under a filesystem.
© 2024 Linux New Media USA, LLC – Legal Notice