Adding a Service to Autostart (CentOS 6/7)

CentOS 6

To add a service to autostart, there is chkconfig service. By default, freshly installed CentOS distribution package includes many additional services.

The syntax of the service:

chkconfig --list service_name

chkconfig --add service_name

chkconfig --del service_name

chkconfig [--level levels] service_name <on|off|reset>

chkconfig [--level levels] service_name

You can see loadable services with the following command:

chkconfig --list | grep on

Check whether httpd is included in autostart:

chkconfig --list httpd

Set performance level 3 and check:

chkconfig --level 3 httpd on

Enable the service at all levels:

chkconfig httpd on

RedHat Linux distribution packages such as CentOS, Fedora includes SysV Init, which consists of 6 levels of system boot (runlevels).

0 — Halt

1 — Single-user text mode

2 — Not used (user-definable)

3 — Full multi-user text mode

4 — Not used (user-definable)

5 — Full multi-user graphical mode (with an X-based login screen)

It is recommended to enable services at the 3rd .

CentOS 7

To set a service to start on boot you can use systemctl:

systemctl enable httpd.service

To make sure a service does not start on boot:

systemctl disable httpd.service

You can check if a service is enabled or disable:

systemctl status httpd.service