Thursday, 5 September 2019

chkconfig - Unix, Linux Command

Linux Tutorial and Materials, Linux Online Exam, LPI Learning

NAME


chkconfig - Updates and queries runlevel information for system services.

SYNOPSIS


chkconfig --list [name]
chkconfig --add name
chkconfig --del name
chkconfig [--level levels] name
chkconfig [--level levels] 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 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 can 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 can 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.

OPTIONS


--level levels: The run levels an operation should pertain to. Given as a string of numbers from 0 to 7. For example, --level 35 specifies runlevels 3 and 5.

--add name: Add 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: Delete the service from chkconfig management, and remove any links in /etc/rc[0-6].d which pertain to it. 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: List all of the services which chkconfig knows about, and whether they are stopped or started in each runlevel. If name is specified, information is only displayed about service name.


EXAMPLES


To list all startup services in alphabetic order.

$ chkconfig --list | sort | less
auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
...

To list the auditd service

$ chkconfig --list auditd
auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

To turn auditd off in runlevels 3, 4, and 5.

$ chkconfig --level 345 auditd off
auditd 0:off 1:off 2:on 3:off 4:off 5:off 6:off

Related Posts

0 comments:

Post a Comment