Linux under the chkconfig command detailed _linux

Source: Internet
Author: User

Chkconfig command

Commands under Linux are chkconfig used primarily to update (start or stop) and to query run-level information for system services. Remember chkconfig not to automatically disable or activate a service immediately, it simply changes the symbolic connection.

Using syntax

Chkconfig [–add][–del][–list][System Services] or Chkconfig [–level < rank code >][system Services][on/off/reset]

chkconfigDisplays the usage when no parameters are running. If you add a service name, check to see if the service is starting at the current run level. Returns true if it is, or false. If On,off or reset is specified after the service name, chkconfi the startup information for the specified service is changed. On and off means that the service is started and stopped, and reset refers to resetting the service's startup information, regardless of what the initialization script for the problem specifies. On and off switches, the system defaults to run-level 3,4,5 only, but reset can be valid for all run levels.

Parameter usage

–addincrease the specified system service, allow chkconfig instructions to manage it, and add relevant data to the system-initiated narrative file.

–del deletes the specified system service, is no longer chkconfig managed by the command, and deletes the relevant data in the system-initiated narration file.

–level< Level code > specifies which execution level the system service should be opened or closed.

Level 0 means: the shutdown

Level 1: Single user mode

Level 2 means: Multi-user command-line mode with no network connection

Level 3 means: Multi-user command-line mode with network connections

Level 4 indicates: Not available

Level 5 means: Multi-user mode with graphical interface

Level 6 indicates: reboot

It is necessary to note that the level option can specify the run levels to view, not necessarily the current run level. For each run level, there can be only one startup script or stop script. When the run level is switched, Init does not restart the service that has started, nor does it stop the service that has stopped.

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 a different run level is displayed.

chkconfig –add name : To add a new service. Chkconfig ensure that each run level has a start (S) or Kill (K) entry. If it is missing, it is automatically created from the default init script.

chkconfig –del name: Deletes the service and deletes the associated symbol connection from the/ETC/RC[0-6].D.

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

Run-level files:

Each chkconfig managed service needs to be annotated with two or more lines of script under the corresponding INIT.D. The first line tells the chkconfig default boot run level and the priority of the start and stop. If a service does not start at any run level by default, then use – instead of run level. The second line describes the service and can be used to cross-line annotations.

For example, Random.init contains three lines:

# chkconfig:2345
# description:saves and restores system entropy pool for \
# higher quality random Generation.

Use Example:

chkconfig –list  #列出所有的系统服务

chkconfig –add httpd #增加httpd服务

chkconfig –del httpd#删除httpd服务

chkconfig –level httpd 2345 on#设置httpd在运行级别为2, 3, 4, 5 cases are on (open) state

chkconfig –list #列出系统所有的服务启动情况

chkconfig –list mysqld#列出mysqld服务设置情况

chkconfig –level 35 mysqld on#设定mysqld在等级3和5为开机运行服务, –level 35 indicates that the operation is performed only on levels 3 and 5, on indicates startup, off is off

chkconfig mysqld on#设定mysqld在各等级为on, "Each Grade" includes 2, 3, 4, 5 grade

How to add a service:

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

chkconfig –add servicename#在chkconfig工具服务列表中增加此服务, at this time the service will be given k/s entrance in the/ETC/RC.D/RCN.D;

chkconfig –level 35 mysqld on#修改服务的默认启动等级.

Summarize

The above is about Linux under the Chkconfig command of all content, I hope the content of this article for everyone's study or work can bring certain help, if there is doubt you can message exchange.

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.