When we use chkconfig --list When It's going to happen again  123456 Such a level . When a certain level is on
He'll turn it on , When he was off He doesn't boot himself when he's on . So what's the reason for that ? His
What is the principle ?

see chkconfig Result :

reflection Why? We set it up 3 Level on He'll turn it on ?
Remember the level of automatic power on ? What level do we use by default ?
What we start by default is  /etc/rc.d/rc3.d/   All the scripts in this

take sshd As an example : Let's take a look at the boot up rc3.d The script in the

What we see now is : This file It's actually a soft connection file He pointed to  /etc/init.d/sshd The entity file of . But the strange thing is that his name is S55sshd   instead of sshd, Okay , We're going to turn it off now, turn it on and start it up , Look again. :

See the Chu people ? Comrades , There's a transfiguration on this thing .. He is no longer S55 了 It becomes k25sshd

Is it a surprise , It's undead and unexpected ??   So why is this ?
Actually It's all just source files :
Let's edit this file to see what's going on inside :

Let's focus on this one , See clearly ? There is one 55 and 25   Is it the same as just now k25  s55 It's like ?
explain :   there 2345 It's the boot level
Once the system recognizes that it is 3 It's started at the next level sshd service It's automatic /etc/init.d/sshd A new one called S55sshd The file of , Once stopped He'll delete it immediately S55sshd file , And then generate a K25sshd The file of ... They start or stop   They always point to the original script . So do you understand the meaning here ?

1. When we set a program in the script to start automatically after boot up , He'll be in /etc/init.d/ A directory of Added a The soft connection points to the source file .
2. When we turn off the boot of a program , He'll be in /etc/init.d/ Add a soft connection to the source file .

When we understand this principle , We do the following   Do not apply chkconfig Just let him on perhaps off

Let's see now sshd What is the state of ?
[root@oldboyedu-sh01 ~]# chkconfig --list | grep sshd
sshd 0:off   1:off   2:on   3:on   4:on   5:on   6:off

It can be seen that at present sshd Of 3 Level is on, Now let's do the following :

Delete this file , We'll do it ourselves Make a shortcut to sshd
[root@oldboyedu-sh01 ~]# ln -s /etc/init.d/sshd /etc/rc.d/rc3.d/K25sshd
that Now let's look at it again sshd Status of the service

He became off 了 ? Isn't surprise ? No surprise ?? So now you understand his principle ?

principle :
Any file needs to be booted , So it's the same thing as /etc/rc.d/rc3.d/ in Set up a
The soft connection points to the entity file , Their launch is S start   Not starting is K start . On and off
All by file control .

If you don't believe it, we'll check sshd The configuration file :

here :
2345   Express Level
55 Open for indication
25 Means closing

We want to create a file to boot It can also be configured like this :
#chkconfig: 2345 55 25
#description: SSH is a protocol for secure remote shell access.
Subsequent use chkconfig --add  [ file name ]   Add to i The system is starting up
Then we can do it later The system level It's starting up , Do you understand ?