Use chkconfig to easily manage startup programs

Source: Internet
Author: User
Tags stop script
Article Title: Use chkconfig to easily manage startup programs. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

This article introduces chkconfig, which provides detailed instructions for Linux administrators to easily manage many symbolic connections under the/etc/rc [0-6]. d directory. The Linux cainiao can also understand and understand the concept of running level in Linux through this article.

Unlike DOS or Windows, 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 the Linux running-level switch, the system will automatically find the corresponding running-level directory/etc/rc [0-6]. files starting with K and S under d are executed in 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

There are 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 whether the service is started 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.

Option Description: -- level levels specifies the running level, which consists of numbers 0 to 7. For example, -- level 35 indicates the running level 3 and 5. -- Add name: This option adds 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. -- Del name is used to delete the service and delete the connection from/etc/rc [0-6]. d. -- List name list. If a name is specified, only the specified service name is displayed. Otherwise, the statuses of all services at different running levels are listed. Each service in the running-level file 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 lines: # chkconfig: 2345 20 80 # description: Saves and restores system entropy pool for \ # 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.

Related Article

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.