Linuxchkconfig overview the Linuxchkconfig command is used to update (start or stop) and query system service running level information. Remember that chkconfig does not automatically disable or activate a service immediately, but simply changes the symbolic connection. The Linuxchkconfig command uses the syntax :...
Linux chkconfig overview
The Linux chkconfig command is used to update (start or stop) and query the running level information of the system service. Remember that chkconfig does not automatically disable or activate a service immediately, but simply changes the symbolic connection.
Linux chkconfig command syntax:
Chkconfig [-- add] [-- del] [-- list] [system service] or chkconfig [-- level <等级代号> ] [System service] [on/off/reset]
The Linux chkconfig command displays usage when no parameter is required to run. If the service name is added, check whether the service is started at the current running level. If yes, true is returned; otherwise, false is returned. If on, off, or reset is specified after the service name, chkconfi changes the startup information of the specified service. On and off indicate that the service is started and stopped, and reset indicates that the service startup information is reset, no matter what is specified by the faulty initialization script. On and off switches. by default, the system is only valid for runtime 3, 4, and 5, but the reset can be effective for all operation levels.
Linux chkconfig command parameter usage:
-- Add adds the specified system service, enables the chkconfig command to manage it, and adds relevant data in the system startup description file.
-- Del: deletes the specified system service. it is no longer managed by the chkconfig command, and relevant data is also deleted in the description file started by the system.
-- Level <等级代号> Specify the execution level of the Read system service.
Level 0: Shutdown
Level 1: Single user mode
Level 2: Multi-user command line mode without network connection
Level 3: Multi-user command line mode with network connection
Level 4: Unavailable
Level 5: Multi-user mode with graphic interface
Level 6: Restart
It should be noted that the level option can specify the running level to be viewed, not necessarily the current running level. For each running level, only one startup script or stop script is allowed. When you switch to the running level, init does not restart the started service or stop the stopped service again.
Chkconfig -- list name: displays the running status information (on or off) of all running system services ). If the name is specified, only the status of the specified service at different running levels is displayed.
Chkconfig -- add name: add a new service. Chkconfig ensures that each running level has a startup (S) or kill (K) entry. If the init script is missing, it is automatically created from the default init script.
Chkconfig -- del name: delete the service and delete the connection from/etc/rc [0-6]. d.
Chkconfig -- level [levels] name: Sets whether a service is started, stopped, or reset at the specified running level.
Linux chkconfig command run-level file:
Each service managed by chkconfig needs to add two or more lines of comments to the script in the corresponding init. d. The first line tells chkconfig the default startup running level and the priority of start and stop. If a service is not started at any running level by default, use-to replace the running level. The second line describes the service. you can use the \ cross-line comment. For example, crond contains three rows:
# Chkconfig: 2345 90 60
# Description: cron is a standard UNIX program that runs user-specified \
# Programs at periodic scheduled times. vixie cron adds \
# Number of features to the basic UNIX cron, including better \
# Security and more powerful configuration options.
# Processname: crond
Linux chkconfig command example:
Chkconfig -- list # list all System Services
Chkconfig -- add httpd # add httpd service
Chkconfig -- del httpd # Delete the httpd service
Chkconfig -- level 2345 httpd on # set httpd to on when the running level is 2, 3, 4, or 5.
How to add a service using the Linux chkconfig command:
1. the service script must be stored in the/etc/ini. d/directory;
2. chkconfig -- addservicename
Add this service to the chkconfig tool service list. in this case, the service will be assigned a K/S entry in/etc/rc. d/rcN. d;
3. chkconfig -- level 35 mysqld on
Modify the default service start level
Chkconfig iptables on enables the firewall and starts as the system starts.
Chkconfig iptables off disable the firewall and it will not start as the system starts.