chkconfig
chkconfig
The chkconfig command in Linux is used to manage services and their runlevels. It is primarily associated with systems using the SysV init system, which is common in older Linux distributions. Here’s an explanation of how chkconfig works and its usage:
Purpose of chkconfig
chkconfigService Management:
chkconfigallows system administrators to configure services to start or stop automatically at various runlevels during system startup or shutdown.
Runlevels:
Runlevels represent different states of the system, such as single-user mode, multi-user mode with networking, and shutdown.
Each runlevel can have specific services configured to start or stop automatically.
Usage Examples
Viewing Service Status:
To see the status of a service and its runlevel configuration:
chkconfig --list <service_name>This command lists the runlevels at which
<service_name>is configured to start (on) or not start (off).
Enabling a Service:
To enable a service to start automatically at specific runlevels:
chkconfig <service_name> onThis command configures
<service_name>to start at the default runlevels defined in its init script.
Disabling a Service:
To disable automatic startup of a service:
chkconfig <service_name> offThis command prevents
<service_name>from starting automatically at any runlevel.
Setting Default Runlevels:
Administrators can specify the default runlevels for starting and stopping a service:
chkconfig --level <runlevel> <service_name> on chkconfig --level <runlevel> <service_name> offReplace
<runlevel>with the desired runlevel (e.g.,3,5) and<service_name>with the name of the service.
chkconfig with systemd
chkconfig with systemdCompatibility:
While
chkconfigis associated with SysV init, some Linux distributions may provide compatibility layers forchkconfigto managesystemdservices.However,
systemctlis the preferred command for managingsystemdservices (systemctl enable,systemctl start, etc.).
Conclusion
Understanding chkconfig is essential for managing services in Linux distributions that use the SysV init system. It provides a straightforward way to configure services to start or stop automatically at different runlevels. As Linux evolves, systemd has largely replaced SysV init, but chkconfig remains relevant in legacy environments and for systems maintaining SysV compatibility. For modern systemd-based systems, administrators should use systemctl commands for service management.
help
Last updated