Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of init of Linux system service

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the use of init of Linux system service. It is very detailed and has certain reference value. Friends who are interested must finish reading it.

The Init process is the initiator and controller of all processes. Because in any Unix-based system (such as linux), it is * running processes, the number of the init process (Process ID,PID) is always 1. If something goes wrong with init, the rest of the system will collapse.

The init process serves two purposes. The role is to play the role of terminating the parent process. Because the init process is never terminated, the system can always be sure of its existence and refer to it when necessary. If a process is terminated before the end of the whole child process that it spawns, there will be situations where init must be used as a reference. At this point, those child processes that have lost their parent process will have init as their parent process. By quickly executing the ps-af command, you can list many processes whose parent process ID (Parent Process ID,PPID) is 1.

The second role of init is to manage various runtime levels by running the corresponding program when it enters a particular run level (Runlevel). Its function is defined by the / etc/inittab file.

1. / etc/inittab file

The / etc/inittab file contains all the information necessary for init to start the runlevel. The format of each line of statements in this file is as follows:

Id: runlevels: action: process

Note: statements that begin with # are comment statements. Take a look at your own / etc/inittab file and you can see that it is full of comments. If you do need to make any changes to the / etc/inittab file (which usually doesn't happen), remember to add some comments to explain why those changes were made.

2. Telinit command

The mysterious power to tell init when to switch the system runlevel is actually the Telinit command. This command has two command-line arguments: one to inform init that it is ready to switch to the past runlevel, and the other is-tsec, where sec is the amount of time in seconds to wait before notifying init.

Note: it is up to init to decide whether to actually switch runlevels. Obviously, it often switches, otherwise this command would not be so useful. In most concrete implementations of Unix operating systems, including linux, the Telinit command is really just a symbolic link to an init program. Based on this, many people prefer to use init to switch directly to the runlevel they want to go to rather than using Telinit. Personally, I find it easier to understand and remember using Telinit to switch runlevels.

The above is all the contents of the article "what is the use of init for Linux system Services". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report