In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces you how to use the Linux chkconfig command, the content is very detailed, interested friends can refer to, hope to be helpful to you.
The Linux chkconfig command is mainly used to update (start or stop) and query the run-level information of system services. Keep in mind that chkconfig does not automatically disable or activate a service immediately, it simply changes symbolic connections.
The Linux chkconfig command uses syntax:
Chkconfig [--add] [--del] [--list] [system Services] or chkconfig [--level] [system Services] [on/off/reset]
The Linux chkconfig command displays usage when it runs with no parameters. If you add the service name, check to see if the service is started at the current run level. If yes, return true, otherwise return false. If on,off or reset is specified after the service name, chkconfi changes the startup information of the specified service. On and off refer to the service being started and stopped, respectively, and reset refers to the startup information of the reset service, regardless of what is specified in the problematic initialization script. On and off switches, by default, are only valid for runlevel 3, 4, and 5, but reset is valid for all runlevels.
Linux chkconfig command parameter usage:
-- add adds the specified system service so that the chkconfig instruction can manage it, and at the same time adds relevant data to the narrative file started by the system.
-- del deletes the specified system service, is no longer managed by the chkconfig instruction, and deletes the relevant data in the narrative file started by the system.
-- level specifies at which execution level the read system service will be turned on or off.
Level 0 indicates that the computer is turned off
Level 1 means: single user mode
Level 2 means: multi-user command line mode without network connection
Level 3 means: multi-user command line mode with network connection
Level 4 means: not available
Level 5 means: multi-user mode with graphical interface
Level 6 means: 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.
Chkconfig-- list name: displays the running status information (on or off) of all runlevel system services. If name is specified, only the status of the specified service at different runlevels is displayed.
Chkconfig-- add name: add a new service. Chkconfig ensures that each runlevel has a startup (S) or kill (K) entry. If it is missing, it is automatically created from the default init script.
Chkconfig-- del name: delete the service and remove the associated symbolic link from / etc/rc [0-6] .d.
Chkconfig-- level [levels] name: sets whether a service is started, stopped, or reset at the specified runtime level.
Linux chkconfig command 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, crond contains three lines:
# chkconfig: 2345 90 60
# description: cron is a standard UNIX program that runs user-specified\
# programs at periodic scheduled times. Vixie cron adds a\
# number of features to the basic UNIX cron, including better\
# security and more powerful configuration options.
# processname: crond
Example usage of the Linux chkconfig command:
Chkconfig-- list # lists all system services
Chkconfig-add httpd # add httpd services
Chkconfig-- del httpd # Delete httpd service
Chkconfig-- level 2345 httpd on # sets httpd to be on when runlevels are 2, 3, 4 and 5
The Linux chkconfig command how to add a service:
1. Service scripts must be stored in the / etc/ini.d/ directory
2.chkconfig--addservicename
Add this service to the list of chkconfig tool services, and the service will be given the KUnip S entry in / etc/rc.d/rcN.d
3.chkconfig-level 35 mysqld on
Modify the default startup level of the service
Chkconfig function description: check and set up various services of the system.
Syntax: chkconfig [--add] [--del] [--list] [system Services] or
Chkconfig [--level] [system Services] [on/off/reset]
Note: this is a program developed by redhat in accordance with gpl rules, which can query which system services, including various daemon, will be executed by the operating system in each execution level (runlevel).
Linux os divides the operating environment into the following seven levels:
0: shutdown (please do not switch to this level)
1: text interface in single user mode
2: multi-user mode text interface, without network file system (NFS) function
3: multi-user mode text interface, with network file system (NFS) function
4: some distributions of linux use this level to enter x windows system
5: some distributions of linux use this level to enter x windows system
6: restart
Parameter:-- add adds the specified system service
-- del deletes the specified system service
-- level specifies the execution level in which the system service should be turned on or off
-- list lists all system services and level codes that can currently be managed from the chkconfig directive
On/off/reset registers at the specified execution to turn on / off / reset the system service
The chkconfig command is mainly used to update (start or stop) and query the run-level information of system services. Keep in mind that chkconfig does not automatically disable or activate a service immediately, it simply changes symbolic connections.
Syntax:
Chkconfig-- list [name]
Chkconfig-add name
Chkconfig-del name
Chkconfig [--level levels] name
Chkconfig [--level levels] name
Chkconfig displays usage when it runs with no parameters. If you add the service name, check to see if the service is started at the current run level. If yes, return true, otherwise return false. If on,off or reset is specified after the service name, chkconfi changes the startup information of the specified service. On and off refer to the service being started and stopped, respectively, and reset refers to the startup information of the reset service, regardless of what is specified in the problematic initialization script. On and off switches, the system is only valid for runlevel 3, 4 and 5 by default, but reset is valid for all runlevels.
The-- level option specifies the runlevel to view, not necessarily the current runlevel.
It is important to note that 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.
Chkconfig-- list: displays the running status information (on or off) of all runlevel system services. If name is specified, only the status of the specified service at different runlevels is displayed.
Chkconfig-- add name: add a new service. Chkconfig ensures that each runlevel has a startup (S) or kill (K) entry. If it is missing, it is automatically created from the default init script.
Chkconfig-- del name: delete the service and remove the associated symbolic link from / etc/rc [0-6] .d.
Chkconfig [--level levels] name: sets whether a service is started, stopped, or reset at the specified runtime level. For example, to stop the nfs service at the 3re4p5 runlevel, the command is as follows:
Chkconfig-level 345 nfs off
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.
In addition, the concept of the runtime level of the Linux system is introduced:
There are many kinds of runlevels in Linux, the common one is the multi-user 2jin3pr 4jin5, many people know that 5 is the level at which X-Windows is run, and 0 is the shutdown. Run-level changes can be switched through the init command. For example, suppose you want to keep the system in a single-user state, then you can use init1 to switch. During the run-level switching of Linux, the system automatically looks for the files starting with K and S under the corresponding runtime directory / etc/rc [0-6] .d, and executes these scripts in the following numerical order. Maintaining these scripts is tedious, and Linux provides chkconfig commands to update and query system services at different runtime levels.
On how to use the Linux chkconfig command to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.