Details about the chkconfig Function

Source: Internet
Author: User
Details about the chkconfig function-general Linux technology-Linux technology and application information. The following is a detailed description. ,
Linux can have multiple running levels. Common examples are 2, 3, 4, and 5 of multiple users. Many people know that 5 is the level of running X-Windows, while 0 is the shutdown. You can use the init command to change the running level. For example, if you want to maintain the system to enter the single-user status, you can use init 1 to switch. During a Linux running-level switch, the system

The system automatically finds the files starting with K and S in the/etc/rc [0-6]. d directory at the running level, and executes these scripts in the numerical order. The maintenance of these scripts is cumbersome. Linux provides the chkconfig command to update and query system services at different running levels.


Syntax:


Chkconfig -- list [name]

Chkconfig -- add name

Chkconfig -- del name

Chkconfig [-- level levels] name

Chkconfig [-- level levels] name



Chkconfig has five functions: Add a service, delete a service, list a service, change the startup information, and check the startup status of a specific service.


When chkconfig does not have a parameter for running, the usage is displayed. If the service name is added, check the service

Whether to start at the current running level. If yes, true is returned; otherwise, false is returned. The -- level option specifies the running level to be viewed, not necessarily the current running level.


If on, off, or reset is specified after the service name, chkconfig changes the startup information of the specified service. On and off indicate the start and stop of the service when the running level is changed. Reset refers to the initialization service information, no matter what is specified by the problematic initialization script.


For on and off switches, the system is only valid for 3, 4, and 5 by default, but the reset can be valid for all running levels. When the -- level option is specified, you can select a specific running level.


It must be noted that for each running level, there can be only one start script or stop script. When you switch to the running level, init does not restart the started service or stop the stopped service again.



Options:


-- Level levels


A running-level string consisting of numbers 0 to 7, for example:


-- Level 35 indicates the running level 3 and 5.


-- Add name


This option adds a new service, and chkconfig ensures that there is

Start (S) or kill (K) entries. If there is a lack of init, the default init

The script is automatically created.


-- Del name


Delete a service and delete the connection from/etc/rc [0-6]. d.


-- List name


List. If the name is specified, only the specified service name is displayed. Otherwise

The status of all services at different running levels.



Running files


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, random. init contains three rows:

# Chkconfig: 2345 20 80

# Description: Saves and restores system entropy pool \

# Higher quality random number generation.


It indicates that the random script should be started at runtime Level 2, 3, 4, 5. The start priority is 20, and the Stop priority is 80.


Now, let's take a look at the script in the/etc/rc. d/init. d directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.