In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "the usage of Linux basic command chkconfig". In daily operation, I believe many people have doubts about the usage of Linux basic command chkconfig. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "the usage of Linux basic command chkconfig"! Next, please follow the editor to study!
Chkconfig
Starting or shutting down the system service and setting the running level of the service, this instruction does not start or stop the service immediately, but has an effect when it is powered on.
Chkconfig provides a simple command-line tool for maintaining the / etc/rc [0-6] .d directory hierarchy, eliminating the need for system administrators to directly manipulate many symbolic links in these directories. This chkconfig implementation is inspired by the chkconfig command in the IRIX operating system. However, this version does not maintain configuration information outside the / etc/rc [0-6] .d hierarchy, but manages symbolic links in / etc/rc [0-6] .d directly. This will leave all configuration information about starting the service init in a single location.
Chkconfig has five different functions: add new services for management, remove services from management, list current startup information for services, change startup information for services, and check the startup status of specific services.
When there is only one service name after the chkconfig, it checks to see if the service is configured to start at the current runtime. If so, chkconfig returns true; otherwise returns false. The "--level" option can be used to cause the chkconfig query to specify the service status under the runlevel, rather than the current runlevel. When you run chkconfig with the "--list" parameter or when there are no parameters at all, a list of all services and their current configuration is displayed.
If you specify one of on, off, reset, or resetpriorities after the service name, chkconfig changes the startup information for the specified service. The on and off flags will cause the service to start or stop at the changed runlevel, respectively. The reset flag resets the on/off status of all runlevels of the service to the look specified in the init script file, with a query when it is reset. The resetpriorities flag, on the other hand, directly resets the on/off state of the service to what is specified in the init script. By default, the on and off options affect only runlevels 2, 3, 4, and 5, while reset and resetpriorities affect all runlevels. Note that for each service, each runlevel has a start script or a stop script. When you switch runlevel, init will not restart services that are already started or stop services that are not running.
Chkconfig can also manage xinetd scripts through the xinetd.d configuration file, and the xinetd service only supports on, off,-- list.
Chkconfig supports a "--type" parameter, which is valid when several services share a name. The services that support this option can be sysv and xinetd.
The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.
1. Grammar
Chkconfig [--list] [--type type] [name]
Chkconfig-add name
Chkconfig-del name
Chkconfig-override name
Chkconfig [--level levels] [--type type] name
Chkconfig [--level levels] [--type type] name
2. List of options
Option
Description
-- help
Help information
-- version
Display command version information
-- list service name
This option lists all services known to chkconfig and whether they are stopped or started at each runlevel. If a name is specified, only information about the service name is displayed.
-- add service name
Increase services. When adding a new service, chkconfig ensures that the service has a startup item or a kill item at each run level. If such an entry is missing at any run level, chkconfig creates the appropriate entry according to the default values in the init script. Note that the default entry in the "INIT INFO" section takes precedence over the default run level in initscript; if there are any necessary start or stop entries, the start and stop priorities of the script are adjusted to take into account these dependencies.
-- del service name
Remove the service from chkconfig management, and any symbolic links in / etc/rc [0-6] .d associated with it are removed.
-- level [levels] [name] [on | off | reset]
Sets the boot state of the specified service at the specified run level, which can be 0: 6. For example: chkconfig-level 35 vsftpd on
-- override name
If the / etc/chkconfig.d/name file now exists and differs from the underlying configuration script, change the configuration file for the service name instead of using the underlying configuration.
3. About the run level
Each service that should be managed by chkconfig needs to add two or more lines of comments to its init.d script. The first line tells chkconfig at which run level the service should be started by default, as well as the start and stop priority levels. If the service should not be started at any runlevel by default, you should use "-" instead of the runlevel list. The second line contains a description of the service, and you can continue to extend multiple lines with a backslash. For example, there are three lines of comments in random.init
# chkconfig: 2345 20 80
# description: Saves and restores system entropy pool for\
# higher quality random number generation.
This means that the random script should start at levels 2, 3, 4, and 5, its start priority should be 20, and its stop priority should be 80.
Chkconfig also supports left-to-right "-" delimiters and will apply them over the available "chkconfig:" lines. For example, the following:
# BEGIN INIT INFO
# Provides: foo
# Required-Start: bar
# Defalt-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Foo init script
# END INIT INFO
In this case, the startup priority of "foo" will be changed, and it will be higher than the "bar" startup priority. Care must be taken when adding dependencies, as they can cause significant changes in the start and stop priorities of many scripts.
4. Examples
1) View all services
[root@localhost] # chkconfig-- list
NetworkManager 0: off 1: off 2: enable 3: enable 4: enable 5: enable 6: close
...
Xinetd-based services:
Chargen-dgram: off
Chargen-stream: off
...
2) View the specified service
[root@localhost] # chkconfig-- list vsftpd
Vsftpd 0: off 1: close 2: close 3: close 4: close 5: enable 6: close
3) set the ftp service to start at levels 3 and 5
[root@localhost ~] # chkconfig-- level 35 vsftpd on / / levels 3 and 5 start
[root@localhost ~] # chkconfig-- list vsftpd / / check whether the setting is successful
Vsftpd 0: off 1: close 2: close 3: enable 4: close 5: enable 6: close
At this point, the study of "the usage of the Linux basic command chkconfig" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.