Run Level Numbers
A run level is a state of init and the whole system that defines what system services are operating. Run levels are identified by numbers.
Run level numbers (init 0 to init 6)
0 Halt the system.
1 Single-user mode (for Troubleshooting).
2 Local Multiuser with Networking but without network service (like NFS)
3 Full Multiuser with Networking
4 Not Used
5 Full Multiuser with Networking and X Windows(GUI) – Graphical mode
Edit Run Level on boot time and services (Redhat)
In redhat /etc/inittab configuration we can modify the default run level on bootime.
id:3:initdefault: l3:3:wait:/etc/rc.d/rc 3
From the first line, we know that init is going to end up at a runlevel of 3 after the system boots.
For services (like network, apache etc) “chkconfig” is used to change the service level.
For example, if we decide to disable crond for runlevel 2, the #chkconfig --level 2 crond off command (executed by root) would turn off crond for the runlevel of 2
Running a user scripts to runlevel
For example Oracle 10G scripts can be started with the “start” argument and terminated with the “stop” argument. This meets the minimum requirements of an initscript that can be used in conjunction with the launch script /etc/rc.d/rc.
Place the script in /etc/rc.d/init.d and run (as root)
chmod +x /etc/rc.d/init.d/oracle
to make the script executable. If you are concerned about normal users seeing the script, you could try more restrictive file permissions, as long as the script is executable by root as a standalone script.
Notice the two comments lines in the script:
#chkconfig: 2345 80 05 #description: Oracle 10G Server
These lines are needed by chkconfig to determine how to establish the initial runlevels to add the service as well as set the priority for the start-and-stop script execution order. These lines denote the script will start Oracle 10G server for the runlevels 2, 3, 4 and 5. In addition, the start priority will be set to 80 while the stop priority will be 05.
Now that the script is in place with the appropriate execute permissions and the required chkconfig comments are in place, we can add the initscript to the chkconfig configuration by typing, as root, chkconfig --add oracle.
Using chkconfig's query feature, we can verify our addition:
[root]# chkconfig --list | grep oracle oracle 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Changing Service run level – Ubuntu:
#sudo apt-get install sysv-rc-conf #sudo sysv-rc-conf Using sysv-rc-conf we can easily manage the services in runlevel.