Sunteți pe pagina 1din 14

Module 03

Change Runlevels n
io
t
a
c
and Shut Down or Reboot
it fi com
r d.
e
Systemx C kaca
I
P
L

u
b
.
n
Li www
//
:
tp
t
h

Objectives

Boot the System


Boot-time Kernel Parameters
Introduction to Kernel Module Configuration

n
o
i
t
Change Runlevels and Shut Down or Reboot System
a
c
Single-User Mode
it fi com
.
Overview of the /etc Directory Tree and the initerProcess
d
a
C
c
Setting the Default Runlevel
a
x
k
u
b
.
Determining Your Systems Runlevel in
w
w
L
I
/w
/
:
LP http

Boot the System

It is the job of a boot loader, such as LILO (Linux Loader)


or GRUB (GRand Unified Bootloader), to launch the Linux
kernel at boot time
n
o
i
Boot-time Kernel Parameters
t
a
c
Set in your boot loaders configuration file (/etc/lilo.conf
it fi coorm
/boot/grub/menu.lst, and /boot/grub/grub.conf)er
.
d
C toacaaccept
However, the Linux kernel also has the capability
x bk
u
information at boot time from a kernel command-line
interface
.
n
w
i
L ww

I
P
L

//
:
tp
t
h

Boot the System


Introduction to Kernel Module Configuration
Linux kernels are modular (modules of code traditionally compiled into the
kernel (a sound driver) are loaded as needed
Can be inserted and removed by the superuser if necessary (using insmod
and rmmod command)
Kernel boot-time messages
As the Linux kernel boots, it gives detailed status of its progress in the
form of console messages:
m
o
c
Kernel identification
d.

i
t
er

n
o
i
t
a
c
fi
a

c
Memory and CPU information
a
k
Information on detected hardware: mice, disks .b
w
Network initialization
w
/w boot time
Kernel module output for modules that load:/at
tp # dmesg | more
t
To view messages from the last boot sequence:
h

I
P
L

x
u
n
i
L

Reviewing system logs:


found in the system logfiles such as /var/log/messages

Change Runlevels and Shut Down or Reboot System

Runlevel
Specifies different ways to use a system by controlling which
services are running
n
Runlevels are specified by the integers 0 through 6 io
t

I
P
L

i
t
er

a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Change Runlevels and Shut Down or Reboot System

Runlevel :

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Change Runlevels and Shut Down or Reboot System

Single-User Mode :
Runlevel 1, the single-user runlevel, is a bare-bones operating
environment intended for system maintenance
nmost
o
Remote logins are disabled, networking is disabled, and
i
t
a
daemons are not started
c
i
f
m mode
i
One common reason you might be forced to uset single-user
o
c
r d.
e
is to correct problems with a corrupt filesystem
a system
C thatacthe
x bk
cannot handle automatically
u
.
n
To switch into single-user mode from another
w
i
runlevel:
w
L
w
I
//
:
P
L http

Change Runlevels and Shut Down or Reboot System

Overview of the /etc Directory Tree and the init Process:


When a Linux system starts, it runs a number of scripts in /etc to
initially configure the system and switch among runlevels.
/etc/rc.sysinit or /etc/init.d/rcS
system initialization script
n
o
i
the script is launched by init at boot time
t
a
c
This script is designed to run before any system daemons
i
are
f
m
i
o
t
started
c
r
.
e
/etc/rc.local
C acad
x initbkscripts
this file is a script that is called after all other
u
.
n
w
i
It contains local customizations affecting
system
w startup and
L
w
I the other
//
provides an alternative to modifying
init scripts
:
P
p
t
L changing
ht
Many administrators prefer to avoid
rc.sysint because
those changes will be lost during a system upgrade. The contents
of rc.local are not lost in an upgrade.

Change Runlevels and Shut Down or Reboot System

Overview of the /etc Directory Tree and the init Process:


/etc/rc:
This file is a script that is used to change between runlevels
/etc/init.d:
n for
This directory contains individual startup/shutdown oscripts
i
t
each service on the system
a
c
Exp: the script /etc/init.d/httpd performs some
m before
it fi checks
o
c
.
starting or stopping the Apache web serverer
d
a
C
c
Valid arguments : start, stop, restart, xstatus,kareload

I
P
L

u
b
.
n
Li www
//
:
tp
t
h

Change Runlevels and Shut Down or Reboot System

Overview of the /etc Directory Tree and the init Process:


The directories /etc/rc0.d through /etc/rc6.d:
The initialization scripts in /etc/init.d are not directly executed
by the init process. Instead, each of the directories /etc/rc0.d
through /etc/rc6.d contains symbolic (soft) links to then scripts in
io
the /etc/init.d directory.
t
a
c
When the init process enters run-level N, it examines
i
all of the
f
m
i
o
t
links in the associated rcN.d directory
c
r
.
e
d
a
C forms
These links are given special names in the
c of KNNname
a
x bk
and SNNname
u
.
n
w
i
K: Kill
w
L
w
I
//
:
P
S: Start
L http
NN: Sequence number
Name: name of the script being linked

Change Runlevels and Shut Down or Reboot System

Setting the Default Runlevel:


To determine the default runlevel at boot time, init reads the
configuration file /etc/inittab

N is a valid runlevel number, such as 3


Never change the default runlevel to 0 or 6

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

Change Runlevels and Shut Down or Reboot System

Determining Your Systems Runlevel:


Use the runlevel command
It displays the previous and current runlevel as integers,
n
o
separated by a space
i
t
a
If no runlevel change has occurred since the system
c
was booted,
i
f
m
i
o
t
the previous runlevel is displayed as the letter
N
c
r d.
e
Exp: a system that was in runlevel 3 and is C
a
now in runlevel
5, the
c
a
x
k
output is:
u
b

I
P
L

n
i
L

.
w
w
w
//

:
tt p
h has just completed
A system with a default runlevel of 5 that
booting, the output would be:

Change Runlevels and Shut Down or Reboot System

Changing runlevels with init and telinit:


The init or telinit command sends signals to the executing init
process, instructing it to change to a specified runlevel
nis simply a
o
The telinit command may be used in place of init.telinit
i
t
a
link to init, and the two may be used interchangeably
c
i

i f com
t
r d.
e
a
C

I
P
L

c
a
x
k
u
b
.
n
i
ww
L
w

//
:
tp
t
h

Change Runlevels and Shut Down or Reboot System

System shutdown with shutdown:


When shutdown is initiated, all users who are logged into terminal sessions
are notified that the system is going down
Logins are blocked to prevent new users from entering the system as it is
being shut down

I
P
L

i
t
er

n
o
i
t
a
c
fi

a
x
k
u
b
.
n
ww
Li
w

//
:
tp
t
h

d
a
c

.c o

S-ar putea să vă placă și