Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the chkconfig command in Linux

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to use the chkconfig command in Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.

The chkconfig command checks and sets up various services of the system. This is a program developed by Red Hat following the GPL rules, which can query which system services are performed by the operating system at each execution level, including various resident services.

Chkconfig checks or sets up various services of the system

Keep in mind that chkconfig does not automatically disable or activate a service immediately, it simply changes symbolic links.

Syntax chkconfig (option) option-- add: add the specified system service to allow the chkconfig instruction to manage it, and at the same time add relevant data to the narrative file started by the system;-- del: delete the specified system service, which is no longer managed by the chkconfig instruction, and delete the relevant data in the narrative file started by the system at the same time;-- level: specify the execution level at which the read system service is to be turned on or off. For the default run level, RHS uses the following levels:

0: shutdown

1: single user mode

2: multi-user mode without network support

3: multi-user mode with network support

4: reserved, unused

5: multi-user mode with network support and X-Window support

6: reboot the system, that is, restart

A detailed explanation of each operational level:

0 means shutdown and the machine shuts down.

1 is a single-user mode, similar to the security mode under Win9x.

2 is multi-user mode, but there is no NFS support.

3 is a complete multi-user mode, which is the standard running level.

4 generally not, it can be used to do some things in some special cases. For example, when the laptop battery runs out, you can switch to this mode to make some settings.

5 is X11, which is in the X Window system.

6 to restart, the machine running init 6 will restart.

It is important to note that the level option specifies the runlevel to view, not necessarily the current runlevel. There can be only one start script or stop script per runlevel. When switching runlevels, init does not restart services that have already been started, nor does it stop services that have been stopped again.

Run-level files:

Each service managed by chkconfig needs to add two or more lines of comments to the script under the corresponding init.d. The first line tells chkconfig the default run level to start and the priority to start and stop. If a service is not started at any runtime level by default, use-instead of runlevel. The second line describes the service and can be commented with\ cross-line comments.

For example, random.init contains three lines:

# chkconfig: 2345 20 80 # description: Saves and restores system entropy pool for\ # higher quality random number generation. The instance chkconfig-list # lists all the system services. Chkconfig-add httpd # adds httpd services. Chkconfig-- del httpd # removes the httpd service. Chkconfig-level httpd 2345 on # sets httpd to be on when runlevels are 2, 3, 4, 5. Chkconfig-list # lists the startup of all the services in the system. Chkconfig-- list mysqld # lists the mysqld service settings. Chkconfig-- level 35 mysqld on # sets mysqld to boot at levels 3 and 5,-- level 35 indicates that the operation is performed only at levels 3 and 5, on indicates startup, and off indicates shutdown. Chkconfig mysqld on # sets mysqld to on at each level, and "each level" includes levels 2, 3, 4, and 5. Chkconfig-level redis 2345 on # makes redis on at runtime levels 2, 3, 4 and 5. How to add a service:

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

Chkconfig-add servicename adds this service to the list of chkconfig tool services, and the service will be given an entry in / etc/rc.d/rcN.d

Chkconfig-the default startup level of the level 35 mysqld on modification service.

Thank you for reading this article carefully. I hope the article "how to use chkconfig commands in Linux" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report