Professional Documents
Culture Documents
Lecture 1-Introduction2
Lecture 1-Introduction2
• Reboot : # init 6
• Shutdown : # init 0
• To manual set default run level at boot time, open /etc/inittab and look for this
line : id:5:initdefault:
The init Control File: /etc/inittab
• The init process uses /etc/inittab as its control file :
• This is a text file, can be edited by the system admin
• init must be told about changes to /etc/inittab by: # init q
• One line per process to run at define run levels
• Lines starting with ‘#’ are comments
• Processes run from /etc/inittab are daemons
• Init read /etc/inittab every time the run level is changed
Structure of /etc/inittab
• Each line has 4 fields seperated by colons:
id:level:action:command
• id Unique identifier for line (up to 4 alphanumeric characters)
• level Run level(s) to activate processs
• action Keyword for how to run process
• command Full path name and parameters of command to be executed
Structure of /etc/inittab
• The main inittab action keywords are:
• Off Do not run this command. Used to retain an entry but to disable it.
• Wait Run command and wait for completion
• Once Run command but do not wait. Daemons processes are often started
this way
• Respawn Run command; If process exists, then rerun it. Used for commands
that have to start again after completion, like getty and ttymon
• Sysinit Run command at first init
• Boot Run command at boot time but do not wait
• Bootwait Like boot but wait for completion
• Initdefault Defines default boot level
/etc/inittab
# more /etc/inittab
...
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
Run Command Scripts
• The run commands scripts are kept under /etc/rc.d/ and are initiated by init with
directions from /etc/inittab
• The script called rc itself runs startup programs in sub-directories under /etc/rc.d/
• rc 0 looks in /etc/rc.d/rc0.d for runlevel 0
• rc 1 looks in /etc/rc.d/rc1.d for runlevel 1
• rc 2 looks in /etc/rc.d/rc2.d for runlevel 2
• etc …
• These startup programs are symbolic links to the actual scripts in the /etc/init.d/
• The startup link names are formatted: first character is S (started) or K (killed or
stopped), the next two digits identify the order that scripts are executed by rc
program
Changing Run Levels
• Use init command to change between run levels. Syntax :
init <runlevel>
• Examples :
# init 0 Shutdown system
# init 6 Reboot system
# init 3 Change to runlevel 3, multi-user text mode
# init 5 Change to runlevel 5, multi-user X11 mode
ShutDown
• Use shutdown commansd. It differs from “init 0” when allowing to
specify time to exit, warn users what happens, …
• Make sure that you follow the proper shutdown procedure. Do NOT
simply shut off the power
# shutdown Default system shutdown (run level 1)
# shutdown –r now Reboot the system now (run level 6)
# shutdown –h 2:00 Halt the system at 2:00AM (run level 0)
Maintenance Mode
• When the system doesn’t work because problems. The simplest and
best solution is to shut down the system to maintenance mode (run
level 1) or reboot the system to single-user mode (run level S) and try
to fix problems