Linux Commands (001)--Chkconfig

Source: Internet
Author: User

First, the preparation of knowledge

Before explaining the purpose of the Chkconfig command, it is necessary to understand the purpose of the/ETC/RC[0-6].D directory in the Linux system first.

As we all know, the Linux system defines 7 different boot levels, the meanings of these 7 boot levels are as follows:

0: Shutdown 1: Single-user mode 2: Multi-user command line mode with no network connection 3: Multi-user command line mode with network Connection 4: Not available 5: Multiuser mode with graphical interface 6: restart

Therefore, 0-6 in the/ETC/RC[0-6].D directory represents the above 7 boot levels. Let's take a look at what is stored in the/ETC/RC[0-6].D directory, taking/ETC/RC5.D as an example:

... Omit ... lrwxrwxrwx. 1 root root 21:57 k89rdisc. /init.d/rdisclrwxrwxrwx. 1 root root 22:12 k92iptables. /init.d/iptableslrwxrwxrwx. 1 root root 21:58 k99rngd. /init.d/rngdlrwxrwxrwx. 1 root root 21:58 s01sysstat. /init.d/sysstatlrwxrwxrwx. 1 root root 21:58 s02lvm2-monitor. /init.d/lvm2-monitorlrwxrwxrwx. 1 root root 21:57 s08ip6tables. /init.d/ip6tables ... Omitted...

As you can see from the output above, there are some linked files in the/etc/rc5.d that are stored in a directory named/ETC/INIT.D. All right, get ready for the knowledge!

Ii. Use of commands

The purpose of chkconfig is to view the startup information of the system service or to update the operating level of the system service. Let's look at how the man page describes the purpose of Chkconfig: "Chkconfig provides a simple command-line tool for maintaining/ETC/RC[0-6].D's directory hierarchy, by using the tool, Greatly reduces the task of the system administrator in manipulating the symbolic links in these directories. ”

Syntax: chkconfig [--list] [--type type][name]chkconfig--add namechkconfig--del namechkconfig--override namechkconfig [-- Level levels] [--type type] name <on|off|reset|resetpriorities>chkconfig [--level levels] [--type type] Name option:--level: Specifies the runlevel of a service. For example:--level 35 Specifies a run level of 3 and 5;--list: Lists all the services managed by Chkconfig and their startup status under a running level;--add: Add a service to add related symbolic links in/etc/rc[0-6].d directory --del: Delete a service, remove the related symbolic connection from the/ETC/RC[0-6].D directory,--override: Overwrite the same name init under the/ETC/INIT.D directory using the init script under the/ETC/CHKCONFIG.D directory Script

If the service name is followed by on, off, reset, resetpriorities One of them, the Chkconfig command will change the startup information for the specified service, where: on/off is used to indicate the start/stop service, and reset is used according to the startup script (/etc/ The start/stop state of the reset service is defined in the INIT.D directory with the file with the same name as the service name, Resetpriorities is used to reset the start/stop priority of the service based on the definition in the startup script. Take Iptables's init script as an example:

[Email protected] init.d]# vi iptables #!/bin/sh## iptables      Start iptables firewall## chkconfig:2345 (92# descript Ion:  starts, stops and saves Iptables firewall# ... Omit ... # where 2345 is the default boot level for iptables, 08 is the default startup priority, and 92 is the default stop priority.

By default, on and off only affect 2,3,4,5 four runlevel, reset and resetpriorities affect all runlevel. The--level option is used to specify which (several) levels of runlevel will be affected.

If Chkconfig uses the--list parameter or without parameters, the command displays all the services in the system and their runlevel. If Chkconfig--list service_name, the command displays the runlevel of a specified service.

III. Example: Configure a service and turn it on from startup

# Make sure the init script for the service exists in the/ETC/INIT.D directory. # Add service to Chkconfig management chkconfig--add service_name# Configuration service runlevel and status Chkconfig--level/service_name on# confirm configuration Results Chkconfig--list Service_Name or chkconfig--list or chkconfig

 

Linux Commands (001)--Chkconfig

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.