chkconfig - Unix, Linux Command


Advertisements

Previous Page
Next Page  
 

NAME

chkconfig - updates and queries run level information for system services

SYNOPSIS

chkconfig [--list] [--type type][name]
chkconfig --add name
chkconfig --del name
chkconfig --override name
chkconfig [--level levels] [--type type] name<on|off|reset|resetpriorities>
chkconfig [--level levels] [--type type] name

DESCRIPTION

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 with only a service name, 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.

When chkconfig is run with the --list argument, or no arguments at all, a listing is displayed of all services and their current configuration.

If one of on, off, reset, or resetpriorities 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 on/off state for all runlevels for the service to whatever is specified in the init script in question, while the resetprioritiesflag resets the start/stop priorities for the service to whatever is specifed in the init script.

By default, the on and off options affect only runlevels 2, 3, 4, and 5, while reset and resetprioritiesaffects 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.

chkconfig supports a --type argument to limit actions to only a specific type of services, in the case where services of either type may share a name. Possible values for type are sysv and xinetd.

 

OPTIONS

TAG DESCRIPTION
--level levels Specifies the run levels an operation should pertain to. It is given as a string of numbers from 0 to 6. 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; if any Required-Start or Required-Stop entries are present, the start and stop priorities of the script will be adjusted to account for these dependencies.
--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.

--override name If service name is configured exactly as it would be if the --add option had been specified with no override file in /etc/chkconfig.d/name, and if /etc/chkconfig.d/name now exists and is specified differently from the base initscript, change the configuration for service name to follow the overrides instead of the base configuration.
--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.

EXAMPLES

EXAMPLE-1:

 Display configuration status of all services

When 'chkconfig' is executed with option --list, it will display all the services and their startup configuration status.
$ chkconfig –list
output:
NetWorkManager 0:off 1:off 2:off 3:on 4:off 5:on 6:off abrtd 0:off 1:off 2:off 3:on 4:off 5:on 6:off acpid 0:off 1:off 2:on 3:on 4:on 5:on 6:off atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off . .

EXAMPLE-2:

Adds a new service for management by chkconfig.

$ chkconfig --add vsftpd

output:
$ chkconfig --list | grep vsftpd
vsftpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

EXAMPLE-3:

Remove a service:

$ chkconfig --del vsftpd
output:
$ chkconfig --list | grep vsftpd

(Nothing will be displayed)

EXAMPLE-4:

Add or Remove a Service at a particular run-level

$ chkconfig --level 3 vsftpd on
vsftpd 0:off 1:off 2:off 3:on 4:off 5:off 6:off
(The following example will turn on vsftpd service for level 3 ) $ chkconfig --level 5 vsftpd off
vsftpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
(The following example will turn off vsftpd service for level 5 )


EXAMPLE-5:

Script Files under rc.d Subdirectories

Whenever you add or remove a service from chkconfig control, it does the following under the /etc/rc.d sub-directories.

The following example shows that xinetd is enabled for both run level 3 and 5.

So, xinetd will have two files under rc3.d directory, and two files under rc5.d directory. The file that starts with K is used during shutdown (K stands for kill). The file that starts with S is used during startup (S stands for start).

# chkconfig --list | grep xinetd
xinetd                    0:off  1:off  2:off  3:on   4:off  5:on   6:off
xinetd based services:

# cd /etc/rc.d/rc3.d
# ls | grep xinetd
K08xinetd
S14xinetd

# cd /etc/rc.d/rc5.d

# ls | grep xinetd
K08xinetd
S14xinetd


Previous Page
Next Page