Details of the chkconfig command under Linux

  • 2020-05-13 04:23:09
  • OfStack

chkconfig command

Under the Linux chkconfig Commands are primarily used to update (start or stop) and query system service run-time information. Keep in mind that chkconfig Instead of automatically disabling or activating a service immediately, it simply changes the symbolic connection.

Use the syntax

chkconfig [en 13en][en 14en][en 15en][system services] or chkconfig [en 17en] < Level code > ][system services][on/off/reset]

chkconfig When no arguments are run, the usage is displayed. If you add the service name, check to see if the service is started at the current run level. If so, return true, otherwise return false. If you specify on, off, or reset after the service name, then chkconfi Changes the startup information for the specified service. on and off refer to services being started and stopped, respectively, and reset refers to resetting the startup information for a service, regardless of what the problematic initialization script specifies. The on and off switches, by default, only work for runlevels 3, 4, and 5, but reset works for all runlevels.

Parameters of the usage

�add Adds specified system services to allow chkconfig The command manages it and simultaneously adds relevant data to the system startup narrative file.

�del Delete the specified system service, no longer by chkconfig Command management, and at the same time delete the relevant data in the system startup narrative file.

�level < Level code > Specifies in which execution level the read system service is to be turned on or off.

Level 0: represents shutdown

Level 1: single user mode

Level 2 represents: network-connectionless multi-user command line mode

Level 3: multi-user command line mode with network connection

Level 4 means: not available

Level 5: multi-user mode with graphical interface

Level 6 means: reboot

Note that the level option allows you to specify which runlevel to view rather than the current runlevel. There can be only one startup script or one stop script per run level. When switching between runlevels, init does not restart a service that has been started or stop a service that has been stopped again.

chkconfig �list [name] : displays the running status information (on or off) for all run-level system services. If name is specified, only the state of the specified service at different runlevels is displayed.

chkconfig0 : add a new service. chkconfig ensures that each runlevel has one entry to start (S) or kill (K) entry. If it is missing, it is automatically created from the default init script.

chkconfig �del name : delete the service and connect the relevant symbol from /etc/rc[0-6].d delete.

chkconfig [�level levels] name : sets whether a service is started, stopped, or reset at the specified run level.

Run-level files:

each chkconfig Managed services need to be commented with two or more lines under the corresponding init.d script. Line 1 tells us chkconfig The default run level to start and the priority to start and stop. If a service is not started at any runlevel by default, then the woundout is used instead of the runlevel. Line 2 describes the service, which can be commented with \ cross-line.

For example, random.init contains three lines:


# chkconfig: 2345 20 80
# description: Saves and restores system entropy pool for \
# higher quality random number generation.

Examples of use:

chkconfig �list   List all system services

chkconfig �add httpd  Add httpd service

chkconfig �del httpd Remove the httpd service

chkconfig �level httpd 2345 on Set httpd to on (on) at runlevels 2, 3, 4, and 5

chkconfig �list  Lists all service startup conditions for the system

chkconfig �list mysqld # lists the mysqld service Settings

chkconfig �level 35 mysqld on Setting mysqld at levels 3 and 5 is for boot-up operation, and the hang level 35 is for operation at levels 3 and 5 only, on is for startup, off is for shutdown

chkconfig mysqld on Set mysqld to on at all levels. "levels" include levels 2, 3, 4, and 5

How to add 1 service:

Service scripts must be stored in/etc/ini d/directory;

chkconfig �add servicename # increase in chkconfig tool service list this service, the service will be at/etc/rc d/rcN d give K/S entrance;

chkconfig �level 35 mysqld on Modify the default startup level of the service.

conclusion

The above is the whole content of chkconfig command under Linux. I hope the content of this article can bring you some help in your study or work. If you have any questions, you can leave a message to communicate.


Related articles: