CentOS 5 Service Management

In CentOS5, services can be started and stopped from the graphical user interface. For example, if you're using Gnome, go to System...Administration...Server Settings...Services. This opens the "Service Configuration" window. Here you can start, stop and restart services, as well as configure them for runlevels 3 to 5.

I'm running CentOS in a VM, so the GUI takes up a lot of resources. Because of that, I usually login to the CentOS VM using putty. The functionality in the "Service Configuration" window is available on the command line as well.

# list all services and their configuration at all runlevels
[ccarddev@localhost]$ /sbin/chkconfig --list|less

# turn off a service at a certain runlevel...
[ccarddev@localhost]$ sudo /sbin/chkconfig --level 5 tomcat5 off
[sudo] password for ccarddev:
[ccarddev@localhost]$ /sbin/chkconfig --list|grep tomcat
tomcat5         0:off   1:off   2:off   3:off   4:off   5:off   6:off
[ccarddev@localhost]$

# ... and turn it back on
[ccarddev@localhost]$ sudo /sbin/chkconfig --level 5 tomcat5 on
[ccarddev@localhost]$ /sbin/chkconfig --list|grep tomcat
tomcat5         0:off   1:off   2:off   3:off   4:off   5:on    6:off
[ccarddev@localhost]$

# start/stop/restart a service
[ccarddev@localhost]$ sudo /etc/init.d/tomcat5 start
Starting tomcat5:                                          [  OK  ]
[ccarddev@localhost]$ sudo /etc/init.d/tomcat5 restart
Stopping tomcat5:                                          [  OK  ]
Starting tomcat5:                                          [  OK  ]
[ccarddev@localhost]$ sudo /etc/init.d/tomcat5 stop
Stopping tomcat5:                                          [  OK  ]
[ccarddev@localhost]$