What folder is /etc/init.d

To know what is in the /etc/init.d folder, it is best to first understand the relationship between /etc/init.d and /etc/rc.d/init.d

These two folders are actually the same thing, /etc/init.d is a soft link pointing to /etc/rc.d/init.d. And this thing is only available under fedora, there is no /etc/rc.d/ directory under ubuntu, only /etc/init.d, under openSUSE there is /etc/rc.d, directly linked /etc/init.d.

And sometimes you can see directories such as rc0.d/, check the files in these directories, ls -l, and find that they are all soft links.

If you want to understand the relationship here, you must understand the Linux run level. Open /etc/inittab, there should be comments in it,

# 0 - shutdown (never set initdefault to 0, or the system will never start)
# 1 - single-user mode
# 2 - multi-user, no NFS
# 3 - full multi-user mode (standard runlevel)
# 4 - System reserved
# 5 - X11 (x window)
# 6 - reboot (don't set initdefault to 6, otherwise it will keep rebooting)

Different run levels will start different services when booting, so when init is executed after booting (pdi is 1, it is the first process executed after booting, all other processes are descendants of this process) this process, just Different default services will be enabled according to different run levels (fedora reads rc.sysinit).

You can see that scripts in directories such as rc0.d/ are preceded by S or K, where s is start and k is kill. For example, when you switch from run level 5 to 3, some services may be turned off, and the script starting with k will be executed at this time.

And the letter will be followed by a number, which indicates the order of script execution. The smaller the number, the earlier the execution. In many cases, the execution order is very important. For example, to start the Apache service, you must first configure the network interface, otherwise one has no IP. The machine to start the http service is not very funny...

To sum up, the /etc/init.d directory is the script for all services. You can start, close or restart the corresponding service by executing the script and adding parameters. The rc.d/ directory should be turned on by default when it is turned on. And according to the different operation of the system and divided into different directories such as rc0.d/, the directories such as rc0.d/ under ubuntu are directly placed under /etc/.

Different from the above distributions, archlinux uses a BSD-like way. All service scripts are placed in the /etc/rc.d directory (there is no init.d directory), and placing them in this directory does not It means that it will be enabled by default at boot. If you want to enable a service by default, you must add the service you want to enable to DAEMONS in /etc/rc.conf, but in this case, there is no concept of run level, no matter the system is. Which run level up, these services will be started by default.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326642735&siteId=291194637