We already know that every computer takes time to prepare themself before they boot into the operating system that will control everything, such as memory management, file management, input/output, etc. Each computer performs the same method to prepare themself, such as identifying hardware, such as keyboards, mouse, harddisk, CDROM, etc and reports them to your, loading MBR (Master Boot Record) which will eventually boot your operating systems. From this stage, the process will be operating system dependent, since every operating system has it own startup process. In this article, we will see some basic description on how to configure some known startup services on GNU/Linux platforms (i use Mandriva Linux and Slackware). We will not messed up with script file, becase that would be too risky for anyone who doesn't know how startup script works on GNU/Linux, but we will try to use chkconfig, an utility which is used to updates and queries runlevel information for system services.
Before we start configuring, we should know the process before startup script was loaded and executed. In GNU/Linux, there are several phases that had to be done in order to boot we meet the login manager (KDM, GDM, or login utility), but we will not discuss them, since it is a bit technical, but you can find it somewhere on the Internet. Try to use Linux Google to help you find some GNU/Linux information. We will start discussing a phase where the kernel have already loaded in your primary memory (RAM).
After the kernel is loaded, the kernel will call init program. This program runs as root and decide which run levels that will be configured at boot time. Run levels are numbers which GNU/Linux use to determine what kind of high level configuration that will be used by systems. To see your run levels, open your /etc/inittab file with cat /etc/inittab. You will see a line like id:5:initdefault, right? Well.. you have found it. That's the run levels and below are some descriptions about the numbers.
For Slackware, it's kindda different and you should pay attention about this.
/etc/inittab, which you have just seen, is the configuration file for init program. Usually, this file orders the init to execute scripts /etc/rc.d/rc and it will send run levels as the parameter. In RedHat Linux, init will execute /etc/rc.d/sysinit first which will perform basic action, such as time setting, disk error checking, and filesystem mounting. In Mandriva Linux, this file is called /etc/rc.d/rc.sysinit. RC scripts are responsible to operate all service needed by the users. Service are facility that are given by the systems to maintain and manage some common task, such as CUPS to manage printer spooling, crond to organize crontab, etc. When we install GNU/Linux, there will be an option to select service that will be activated on boot (usually after packages installation). In most systems, some services, such as syslog, atd, and crond are services that always active by default, since systems need it, but the rest are not. Services can be found on /etc/rc.d/init.d, except for Slackware which can be found at /etc/rc.d.
How does the systems know what services had to be executed on every different run levels? The answers is located on a directory /etc/rc.d/. In this directory, there are 6 subdirectories which is used to identify what service that will executed on certain run levels. This subdirectories are named rc0.d, rc1.d, rc2.d, rc3.d, rc4.d, rc5.d, and rc6.d. If you want to see all services which are started on run level 3 (text mode), use ls -al /etc/rc.d/rc3.d. You will see some symlink that has a pattern Sxx<ServiceName>, like S99webmin or Kxx<ServiceName>, like K09DM. The first letter (K or S) represent the action; K means stop, and S means start. The next two digits represent the sequence number. Service with lower number will be executed first. If there are some services with same number, then they will picked up alphabetically.
In Slackware, the situation is kindda different, since Slackware inherits some BSD-like distro, so the startup services are a little bit different with other distro, but it's more simple in my opinion. Each service will have a rc. prefix, indicating that it is a services. You can turn it on or off by simply setting it's permission. If you want to activate some service at startup, you just simply add an execute permission on the file and it will be called at startup. For example, to enable SSH Daemon, type
chmod +x /etc/rc.d/rc.sshd
While to disable it, type
chmod -x /etc/rc.d/rc.sshd
After a long wait, finally, you are going to meet chkconfig utility. It is a powerfull command line tool for system administrator to query and updates run level information for system services. Unfortunately, this tool is not an universal tool, since some distro like Slackware doesn't use this tool, so you should check the package list first before you try to call this command. chkconfig has five distinct functions: adding new services for management, removing services from management, listing the current startup information for services, changing the startup information for services, and checking the startup state of a particular service. Below are the syntax for each action :
By default (without any parameter), chkconfig will display usage information. If you run with --list parameter, it will list all services available for all run levels with it's value (on or off). You can try to modify a service by adding --level parameter followed by run level and status (on, off, or reset). For example, to start webmin service on run level 5, you would enter chkconfig --level 5 webmin on.
Every distro has it own implementation of chkconfig utility. I have found that SuSE Linux is using different syntax. You should consult with manual page for your own distro to find out the correct syntax.
Last Update : 5 June 2006 :: 15:10:57
Comments
2 Well, it's a good article, but how can i do it like that on debian system?I have no found chkconfig command on my shell.