To begin, a really handy command that you should get to know is chkconfig. This command will show you whether a service is set to be on or off in each runlevel. If you simply type the command with no options, you will see output like the following:
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
As you can see, the runlevel's are shown, with the corresponding on/off option shown for each. In order to add a service, you need to first create the script to execute and put it into the /etc/init.d directory. If you have software that you have unpacked that has its own script already written, you can simply create a link to that script in the /etc/init.d directory. Either way, once you have done that you can add it as an active service by issuing:
chkconfig --add
The
chkconfig | grep
You should see the above output if the service was successfully added. If you need to change a service to be on or off in a specific runlevel, then the format of the command is:
chkconfig --level 345 httpd off
The numbers after the '--level' are the runlevels to modify. As you can see, you can list whichever levels you want, but no spaces, commas, or anything else. After that is the service to modify, followed by whether it is off or on in the listed runlevels.
To remove a service, simply use:
chkconfig --del
Again, check that it was removed per the above command.
The chkconfig command does have other options available to it, but this should give you a basic overview of how to use it. If you wish to read further, please feel free to read the man page.
It is important to note that chkconfig does not exist on all systems and is typical on Red Hat based systems. If you are on, say, Debian based machines (such as Ubuntu), then you will need to use 'update-rc.d'.
We will save that for another post.....