|Home||Switchboard||Unix Administration||Red Hat||TCP/IP Networks||Neoliberalism||Toxic Managers|
May the source be with you, but remember the KISS principle ;-)
Skepticism and critical thinking is not panacea, but can help to understand the world better
|News||Books||Linux Run Levels||Recommended Links||Reference||/etc/inittab|
|RHEL RC Scripts||Suse RC Scripts||System Shutdown and Rebooting||Creating your own init scripts for Red Hat||Admin Horror Stories||Etc|
Erik Troan from Red Hat designed the chkconfig utility, based on chkconfig under IRIX, a UNIX from Silicon Graphics, Inc.
chkconfig was designed to enable/disable services for automatic launch during system initialization without editing, renaming or moving init scripts.
The key idea is to add a special header in comment section that starts each init script to each init script. Presence of such header permits automatically determine on which levels the script should run and with which priorities. In other words automate handling of symbolic links for init scripts and provide useful reference as for which services are active on what levels. In Red Hat version the header is very simple and well designed. It consists of just two lines:
Here is an example of Red Hat chkconfig header:
#chkconfig: 2345 80 05 #description: Oracle Server
Red Hat implementation is a binary. Scripting language is a better language for writing such utilities and later Suse reimplemented it as Perl script. But in addition to providing Red Hat functionality Suse version redefined the header, adding several additional lines. The net result is a more complex header without too much gain in functionality. Generally Suse startup scripts are so over-engineered that they can be considered a classic instance of Christmas tree syndrome ;-). Ubuntu uses Suse version of chkconfig. We will discuss Red Hat version only, but reference contains Suse man page just for completeness.
Syntax of Red Hat version
chkconfig --list [name]Options:
chkconfig --add name
chkconfig --del name
chkconfig [--level levels] name <on|off|reset>
chkconfig [--level levels] name
Note that future package installs for this service may
run chkconfig --add, which will re-add such links.
To disable a service, run chkconfig name off.
The chkconfig binary resides in /sbin with default permissions that allow any user to execute it, although the user without root privileges can only view the current chkconfig configuration. So any user can get list of services running:
[root]# chkconfig --list | grep ":on"
On each line of output, the first field represents the name of an initscript in /etc/rc.d/init.d. The remaining fields correspond to the runlevels 0-6 along with the status of the script when entering that runlevel. For example, crond would be launched when entering the runlevels 2, 3, 4 and 5 and stopped when entering the runlevels 0, 1 and 6. We can confirm that these settings are true with the find command to search for all files in /etc/rc.d that end with crond:
find /etc/rc.d -name "*cron*" -ls
Notice for each “on” section reported by chkconfig (0, 1, 6), a kill and start scripts are in place
Manually modifying levels on which daemon runs is a mixed blessing as it can interfere with the header of theinit script that chkconfig is using. But sometimes it is necessary. In this case the command is:
chkconfig [--level <levels>] <name> <on|off|reset>
For example, if we decide to disable crond for runlevel 2, the chkconfig --level 2 crond off command (executed by root) would turn off crond for the runlevel of 2. Running chkconfig --list will confirm that crond's configuration has been modified.
Keep in mind that chkconfig does not automatically disable or enable a service immediately. It simply changes the symbolic links. You need to stop the service manually using serive command of running init stip with parameter stop, for example /etc/rc.d/init.d/crond stop.
Finally, you can enable/disable a command for multiple runlevels with one chkconfig command. For example entering
chkconfig --levels 2345 crond on
would set up crond to be started for runlevels 2, 3, 4 and 5.
Some people think that disabling sendmail desirable since it reduces potential security risks. To remove sendmail from chkconfig, type
chkconfig --del sendmail
In case you did not change manually level on which sendmail should start this is adential affect to
chkconfig sendmail off
Affter both cpommand you better chack the result with find. For example:
[root]# find /etc/rc.d -name '*sendmail*' -print /etc/rc.d/init.d/sendmail
Let's use the example script from Managing Initscripts with Red Hat's chkconfig Linux Journal (with some minor modifications)
#!/bin/sh #chkconfig: 2345 80 05 #description: Oracle Server ORA_HOME=/usr/home/oracle/product/11.1.2 ORA_OWNER=oracle if [ ! -f $ORA_HOME/bin/dbstart ] then echo "Oracle startup: cannot start" exit fi case "$1" in "start") su - $ORA_OWNER -c $ORA_HOME/bin/dbstart su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" ;; "stop") su - $ORA_OWNER -c $ORA_HOME/bin/dbshut su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" ;; esac
Note the special header
#chkconfig: 2345 80 05 #description: Oracle Server
It informs chkconfig on which levels and with what priority links to startup script should be created. Those to line is the minimum requirements of an initscript that can be used in conjunction with chkconfig.
These lines are needed by chkconfig to determine how to establish the initial runlevels to add the service as well as set the priority for the start-and-stop script execution order. These lines denote the script will start Oracle 8 server for the runlevels 2, 3, 4 and 5. In addition, the start priority will be set to 80 while the stop priority will be 05.
Now that the script is in place with the appropriate execute permissions and the required chkconfig comments are in place, we can add the initscript to the chkconfig configuration by typing, as root,
chkconfig --add oracle
Using chkconfig's query feature, we can verify our addition:
[root]# chkconfig --list | grep oracle oracle 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Also, we can type our standard find command to see how chkconfig set up the symbolic links:
[root]# find /etc/rc.d -name '*oracle' -print /etc/rc.d/init.d/oracle /etc/rc.d/rc0.d/K05oracle /etc/rc.d/rc1.d/K05oracle /etc/rc.d/rc2.d/S80oracle /etc/rc.d/rc3.d/S80oracle /etc/rc.d/rc4.d/S80oracle /etc/rc.d/rc5.d/S80oracle /etc/rc.d/rc6.d/K05oracle
As requested, the names of the kill links contain the priority 05 while the start links contain 80. If we need to adjust the priorities, (e.g., our stop priority needs to be 03), simply modify the chkconfig comment lines in the initscript for oracle and run the reset command, as shown below. The resulting symbolic links will be renamed accordingly:
[root]# chkconfig oracle reset [root]# find /etc/rc.d -name '*oracle' -print /etc/rc.d/init.d/oracle /etc/rc.d/rc0.d/K03oracle /etc/rc.d/rc1.d/K03oracle /etc/rc.d/rc2.d/S80oracle /etc/rc.d/rc3.d/S80oracle /etc/rc.d/rc4.d/S80oracle /etc/rc.d/rc5.d/S80oracle /etc/rc.d/rc6.d/K03oracle
When inetd was replaced by xinetd in Red Hat 7 chkconfig functionality has been extended to manage some of the functionality of xinetd's Internet services. Sample output is shown below:
[root]# chkconfig --list ... xinetd based services: finger: on linuxconf-web: off rexec: off rlogin: off rsh: off ntalk: off talk: off telnet: on tftp: off wu-ftpd: on
To disable a xinetd feature, perhaps finger, you could type
# chkconfig finger off
When the configuration is changed, the xinetd is signaled automatically to reload the new configuration with the command /etc/init.d/xinetd reload, that is executed by chkconfig. This script performs a kill with the SIGUSR2 signal which instructs xinetd to perform a hard reconfiguration. the active sessions of services offered through xinetd (i.e., Telnet, FTP, etc.) were immediately terminated. That might not be a problem for you, assuming you can plan the best time to disable/enable xinetd services on your system. As an alternative, you can modify the /etc/init.d/xinetd script so that the reload option sends a SIGUSR1 signal, which is a soft reconfiguration. This will restart the services without terminating existing connections.
Adding xinetd services for chkconfig management is as simple as adding an xinetd service file into the /etc/xinetd.d directory. The chkconfig utility will automatically pick it up and make it available for management through the chkconfig utility.
Updated chkconfig packages that resolve several issues with the alternatives utility and provide various man page corrections are now available.
The basic system utility chkconfig updates and queries runlevel information for system services.These updated chkconfig packages provide fixes for the following bugs:
* when the "alternatives" utility was run and an error occurred, no contextual information such as the line number of the error was provided. With this update, upon an error, "alternatives" now provides the line number where the error occurred in the relevant file in the /var/lib/alternatives directory, which helps to diagnose alternatives-related errors. (BZ#441443)* using the "alternatives" utility and selecting the last available option and then uninstalling the program which provided that alternative did not result in the removal of the symbolic links for that option. Because the previously-set alternative was no longer available and the symbolic link remained, the program was then rendered unusable. With this update, when the aforementioned condition is met, the "alternatives" program now recognizes that the program is no longer available and removes the extraneous symbolic link, with the result that the next-best alternative is properly selected, and running the program works as expected. (BZ#525051)
* the chkconfig(8) man page contained a description of the syntax for running chkconfig that differed from the correct description presented when running "chkconfig --help". The man page has been corrected to correspond with the program's help information. (BZ#501225)* the chkconfig(8) man page contained an incorrect reference to runlevel 7, which does not exist (runlevels extend from 0 to 6, inclusive). This update corrects the man page by removing all references to "runlevel 7". (BZ#466740)
* the ntsysv(8) man page referenced a non-existent man page, servicesconf. This reference has been removed. (BZ#516599)All users of chkconfig are advised to upgrade to these updated packages, which resolve these issues
Google matched content
Chapter 1. Boot Process, Init, and Shutdown
CentOS - chkconfig Cloud Computing and Web Hosting Knowledge Center by Rackspace
Managing Initscripts with Red Hat's chkconfig Linux Journal Apr 01, 2001 By Jimmy Ball Old but still useful paper. Much of the material on this page was adapted from this article.
9.2.3. Using the chkconfig Utility (Red HAt
chkconfig(8) - Linux man page
chkconfig - updates and queries runlevel information for system services
chkconfig --list [name]
chkconfig --add name
chkconfig --del name
chkconfig [--level levels] name <on|off|reset>
chkconfig [--level levels] name
chkconfig provides a simple command-line tool for maintaining the /etc/rc[0-6].d directory hierarchy by relieving system administrators of the task of directly manipulating the numerous symbolic links in those directories.
This implementation of chkconfig was inspired by the chkconfig command present in the IRIX operating system. Rather than maintaining configuration information outside of the /etc/rc[0-6].d hierarchy, however, this version directly manages the symlinks in /etc/rc[0-6].d. This leaves all of the configuration information regarding what services init starts in a single location.
chkconfig has five distinct functions: adding new services for management, removing services from management, listing the current startup information for services, changing the startup information for services, and checking the startup state of a particular service.
When chkconfig is run without any options, it displays usage information. If only a service name is given, it checks to see if the service is configured to be started in the current runlevel. If it is, chkconfig returns true; otherwise it returns false. The --level option may be used to have chkconfig query an alternative runlevel rather than the current one.
If one of on, off, or reset is specified after the service name, chkconfig changes the startup information for the specified service. The on and off flags cause the service to be started or stopped, respectively, in the runlevels being changed. The reset flag resets the startup information for the service to whatever is specified in the init script in question.
By default, the on and off options affect only runlevels 2, 3, 4, and 5, while reset affects all of the runlevels. The --level option may be used to specify which runlevels are affected.
Note that for every service, each runlevel has either a start script or a stop script. When switching runlevels, init will not re-start an already-started service, and will not re-stop a service that is not running.
chkconfig also can manage xinetd scripts via the means of xinetd.d configuration files. Note that only the on, off, and --list commands are supported for xinetd.d services.
- Specifies the run levels an operation should pertain to. It is given as a string of numbers from 0 to 7. For example, --level 35 specifies runlevels 3 and 5.
- --add name
- This option adds a new service for management by chkconfig. When a new service is added, chkconfig ensures that the service has either a start or a kill entry in every runlevel. If any runlevel is missing such an entry, chkconfig creates the appropriate entry as specified by the default values in the init script. Note that default entries in LSB-delimited 'INIT INFO' sections take precedence over the default runlevels in the initscript.
- --del name
- The service is removed from chkconfig management, and any symbolic links in /etc/rc[0-6].d which pertain to it are removed.
Note that future package installs for this service may run chkconfig --add, which will re-add such links. To disable a service, run chkconfig name off.
- --list name
- This option lists all of the services which chkconfig knows about, and whether they are stopped or started in each runlevel. If name is specified, information in only display about service name.
Each service which should be manageable by chkconfig needs two or more commented lines added to its init.d script. The first line tells chkconfig what runlevels the service should be started in by default, as well as the start and stop priority levels. If the service should not, by default, be started in any runlevels, a - should be used in place of the runlevels list. The second line contains a description for the service, and may be extended across multiple lines with backslash continuation.
For example, random.init has these three lines:# chkconfig: 2345 20 80 # description: Saves and restores system entropy pool for \ # higher quality random number generation.This says that the random script should be started in levels 2, 3, 4, and 5, that its start priority should be 20, and that its stop priority should be 80. You should be able to figure out what the description says; the \ causes the line to be continued. The extra space in front of the line is ignored.
init(8) ntsysv(8) system-config-services(8)
AuthorErik Troan <email@example.com>
Ubuntu Manpage chkconfig - enable or disable system services
Provided by: chkconfig_11.0-79.1-2_all
chkconfig - enable or disable system services
chkconfig -t|--terse [names] chkconfig -s|--set [name state] chkconfig -e|--edit [names] chkconfig -c|--check name [state] chkconfig -l|--list [--deps] [names] chkconfig -A|--allservices chkconfig -a|--add [names] chkconfig -d|--del [names]
chkconfig is used to manipulate the runlevel links at boot time (see init.d(7)). It can be thought of as a frontend to insserv(8). Chkconfig can run in six different modes: terse list mode, set mode, edit mode, list mode, add mode and delete mode. The last three modes were added for compatiblity reasons.
This mode lists the state of the specified services, or all known services if no service name was provided. Every printed line consists of the name of the service and the runlevels the service is configured for at the moment. If it is configured in no runlevel, off is used instead, if it is configured in the runlevels defined as a default by the start script, on is used. If the service is an enabled inetd or xinetd service, inetd and xinetd are used. Inetd/xinetd services are configured in /etc/inetd.d and /etc/xinetd.d, respectively. You can use the -A or --allservices parameter to get all services (even the boot.*-services) listed. If chkconfig is called without arguments, all services are listed in terse mode.
Set mode is used to configure at which runlevel a service should be started. The arguments must be specified as pairs of service name and new state. You can use on and off as special states to select the default set of runlevels or to disable a service completely. You can use inetd or xinetd to configure a service managed by the inetd/xinetd daemons. If no services are specified, chkconfig reads lines from standard input. Each line must consist of a service/state pair. As this is exactly the output of the terse list mode, this can be used to reconfigure a service specification saved by a former run. If the option -f or --force is also given, insserv is called with a '-f' option.
This mode is a combination of the terse list mode and set mode. It writes the state of all specified services (or all known services, if no service was provided) into a temporary file, starts an editor and re-configures all services to reflect the states of the changed temporary file.
This mode can be used to check the state of a service. chkconfig exits with a return code of '0' if the service is enabled in all of the specified runlevels, otherwise the exit status is '1'. If chkconfig is called with only a service name the current runlevel of the system is used for checking.
List mode prints for each specified service a line that consists of the service name and for runlevels zero to six on or off depending if the service will be started or not. on will be printed in bright green if the output is written to a terminal. If the --deps option is given, the names of the services that must be started before this service is appended to each line. The inetd/xinetd services are listed in extra sections. You can use the -A or --allservices parameter to get all services (even the boot.*-services) listed.
Calls insserv to enable a service and uses list mode to display the new setting afterwards.
Same as add mode, but disable the service.
When no service names are given on the command line, chkconfig defaults to all known services excluding those that are not enabled in runlevels 1 to 6 and start with 'boot.'. Use the --allservices or -A option if you want to see such services as well.
chkconfig list the runlevel configuration of all known services chkconfig apache list the runlevel configuration of the apache web server chkconfig -t apache xntpd list the runlevel configuration of the apache web server and the network time protocol daemon. chkconfig apache on configure the apache web server to be started on next boot time. chkconfig apache 5 configure the apache web server to be started only if the system reaches runlevel 5. chkconfig apache 35 configure the apache web server for runlevel 3 and 5. chkconfig apache on xntpd off configure two services chkconfig finger xinetd configure a xinetd service chkconfig -A >~root/chkconfig.save backup the current configuration chkconfig -s <~root/chkconfig.save restore the configuration chkconfig -e apache xntpd change the runlevel configuration interactively chkconfig -e change the runlevel configuration of all services interactively
/etc/init.d/ path to the boot script base directory as required by the Linux Standard Base Specification (LSB). /etc/inetd.d/ path to the inetd services. See the inetd manpage to find out how to enable this feature. /etc/xinetd.d/ path to the xinetd services.
init.d(7), init(7), inetd(8) xinetd(8) insserv(8)
2003 SuSE Linux AG, Nuernberg, Germany.
Michael Schroeder <firstname.lastname@example.org>
Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers : Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism : The Iron Law of Oligarchy : Libertarian Philosophy
War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda : SE quotes : Language Design and Programming Quotes : Random IT-related quotes : Somerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose Bierce : Bernard Shaw : Mark Twain Quotes
Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 : Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law
Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds : Larry Wall : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOS : Programming Languages History : PL/1 : Simula 67 : C : History of GCC development : Scripting Languages : Perl history : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history
The Peter Principle : Parkinson Law : 1984 : The Mythical Man-Month : How to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite
Most popular humor pages:
Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor
The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D
Copyright © 1996-2020 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.
This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...
|You can use PayPal to to buy a cup of coffee for authors of this site|
Last modified: March, 12, 2019