14
Module 03 Change Runlevels and Shut Down or Reboot System

Module 03 - Change Runlevels and Shut Down or Reboot System

Embed Size (px)

DESCRIPTION

linux

Citation preview

Page 1: Module 03 - Change Runlevels and Shut Down or Reboot System

Module 03

Change Runlevels

and Shut Down or Reboot

System

Page 2: Module 03 - Change Runlevels and Shut Down or Reboot System

Objectives

Boot the System

Boot-time Kernel Parameters

Introduction to Kernel Module Configuration

Change Runlevels and Shut Down or Reboot System

Single-User Mode

Overview of the /etc Directory Tree and the init Process

Setting the Default Runlevel

Determining Your System’s Runlevel

Page 3: Module 03 - Change Runlevels and Shut Down or Reboot System

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

Boot-time Kernel Parameters

Set in your boot loader’s configuration file (/etc/lilo.conf or

/boot/grub/menu.lst, and /boot/grub/grub.conf)

However, the Linux kernel also has the capability to accept

information at boot time from a kernel command-line interface

Page 4: Module 03 - Change Runlevels and Shut Down or Reboot System

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:

– Kernel identification

– Memory and CPU information

– Information on detected hardware: mice, disks…

– Network initialization

– Kernel module output for modules that load at boot time

• To view messages from the last boot sequence: # dmesg | more

Reviewing system logs:

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

Page 5: Module 03 - Change Runlevels and Shut Down or Reboot System

Change Runlevels and Shut Down or Reboot System

Runlevel

Specifies different ways to use a system by controlling which

services are running

Runlevels are specified by the integers 0 through 6

Page 6: Module 03 - Change Runlevels and Shut Down or Reboot System

Change Runlevels and Shut Down or Reboot System

Runlevel :

Page 7: Module 03 - Change Runlevels and Shut Down or Reboot System

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

Remote logins are disabled, networking is disabled, and most

daemons are not started

One common reason you might be forced to use single-user mode

is to correct problems with a corrupt filesystem that the system

cannot handle automatically

To switch into single-user mode from another runlevel:

Page 8: Module 03 - Change Runlevels and Shut Down or Reboot System

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

• the script is launched by init at boot time

• This script is designed to run before any system daemons are

started

/etc/rc.local

• this file is a script that is called after all other init scripts

• It contains local customizations affecting system startup and

provides an alternative to modifying the other init scripts

• Many administrators prefer to avoid changing rc.sysint because

those changes will be lost during a system upgrade. The

contents of rc.local are not lost in an upgrade.

Page 9: Module 03 - Change Runlevels and Shut Down or Reboot System

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:

• This directory contains individual startup/shutdown scripts for

each service on the system

• Exp: the script /etc/init.d/httpd performs some checks before

starting or stopping the Apache web server

• Valid arguments : start, stop, restart, status, reload

Page 10: Module 03 - Change Runlevels and Shut Down or Reboot System

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 the scripts in

the /etc/init.d directory.

• When the init process enters run-level N, it examines all of the

links in the associated rcN.d directory

• These links are given special names in the forms of KNNname

and SNNname

– K: Kill

– S: Start

– NN: Sequence number

– Name: name of the script being linked

Page 11: Module 03 - Change Runlevels and Shut Down or Reboot System

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

Page 12: Module 03 - Change Runlevels and Shut Down or Reboot System

Change Runlevels and Shut Down or Reboot System

Determining Your System’s Runlevel:

Use the runlevel command

It displays the previous and current runlevel as integers,

separated by a space

If no runlevel change has occurred since the system was booted,

the previous runlevel is displayed as the letter N

Exp: a system that was in runlevel 3 and is now in runlevel 5, the

output is:

A system with a default runlevel of 5 that has just completed

booting, the output would be:

Page 13: Module 03 - Change Runlevels and Shut Down or Reboot System

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

The telinit command may be used in place of init.telinit is simply a

link to init, and the two may be used interchangeably

Page 14: Module 03 - Change Runlevels and Shut Down or Reboot System

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