Feb 08 2007
run level and /etc/inittab
Description
The numbers associated with the run levels for a specific distribution are listed in the /etc/inittab
#/etc/inittab (in RHEL 3)
# Default runlevel. The runlevels used by RHS are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:
# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit
l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6
# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
Choose the good runlevel:
Runlevel 0:
it will shutdown your system
Runlevel 1:
It is the single user mode, used by system administrator when you have to fix some problems and everything is going wrong. you’ll be root without password.
Very useful if you forgot your root password, but you have to protect the physical acces to your server.
No user can log in while you are in this runlevel
Runlevel 2:
It is a multi user mode in command line (like the runlevel3) but you don’t have network connection
Runlevel 3:
It is the full multiuser command line mode. (mainly used by every one)
Runlevel 4:
I think it is not really used maybe you can configure it for special purposes…
Runlevel 5:
It is the full multiuser X11 mode.
Runlevel 6:
It will reboot your server
The good choice:
Depending on the server utilisation you have, you’ll choose runlevel 3 or 5
The (very) bad one:
You mustn’t change the initdefault to runlevel 0 (halt) or runlevel 6 (reboot)
because the system will then either immediately shutdown just after starting, or reboot indefinitely….
Changing the inittab configuration:
To make a change you can either edit the conf. file /etc/inittab or use the comand ‘telinit’
[admin@nuxora admin]$man telinit
#
#…. this is an extract ….
#
TELINIT
/sbin/telinit is linked to /sbin/init. It takes a one-character argu-
ment and signals init to perform the appropriate action. The following
arguments serve as directives to telinit:
0,1,2,3,4,5 or 6
tell init to switch to the specified run level.
a,b,c tell init to process only those /etc/inittab file entries having
runlevel a,b or c.
Q or q tell init to re-examine the /etc/inittab file.
S or s tell init to switch to single user mode.
U or u tell init to re-execute itself (preserving the state). No re-
examining of /etc/inittab file happens. Run level should be one
of Ss12345, otherwise request would be silently ignored.
telinit can also tell init how long it should wait between sending pro-
cesses the SIGTERM and SIGKILL signals. The default is 5 seconds, but
this can be changed with the -t sec option.
telinit can be invoked only by users with appropriate privileges.
[admin@nuxora admin]$
[admin@nuxora admin]$
Trap Key:
If the key combination CTRL-ALT-DEL is trapped by one entry in /etc/inittab
then the shutdown command will be called when you’ll press ctrl+alt+del
Everyone who has physical access to the console keyboard could shut the system down.
It will also check if the user is allowed to execute a ’shutdown’. To prevent this, you can
drop this line from /etc/inittab or modify the execution script:
ca::ctrlaltdel:echo “shutdown is not allowed pressing ctrl + alt + del”
