How to enable and disable services in Red Hat

Red Hat, Fedora, and Red Hat based Linux distributions such as CentOS make use of the script called chkconfig to enable and disable the system services running in Linux.

How to enable a service

As an example, lets enable the Apache web server to start in run levels 2, 3, and 5. This is how it is done.

We first add the service using chkconfig script. Then turn on the service at the desired run levels.

# chkconfig httpd --add
# chkconfig  httpd  on --level 2,3,5

This will enable the Apache web server to automatically start in the run levels 2, 3 and 5. You can check this by running the command –

# chkconfig --list httpd


How to disable a service


# chkconfig httpd off
# chkconfig httpd --del

Red Hat/Fedora also have a useful script called service which can be used to start or stop any service. For example, to start Apache web server using the service script, the command is as follows –

# service httpd start

and to stop the service…

# service httpd stop

The options being start, stop and restart which are self explanatory.

Leave a Reply