% DO NOT EDIT GENERATED AUTOMATICALLY FROM gl2.106.2.slides.tex
\input{gl2.slide-header-beamer}% DO NOT EDIT GENERATED AUTOMATICALLY FROM gl2.106.2.slides.tex
\errorcontextlines=99
%% Subtopic Number = '1.106.2'
%% Title from filename: 'Change runlevels and shutdown or reboot system'
%% Weight: 3
%% Description:
%% Candidates should be able to manage the runlevel of the
%%        system. This objective includes changing to single user mode, shutdown
%%        or rebooting the system. Candidates should be able to alert users before
%%        switching runlevel, and properly terminate processes. This objective
%%        also includes setting the default runlevel.
%% Key files, terms, and utilities include:
%%        /etc/inittab
%%        shutdown
%%        init
\title{1.106.2\\Change runlevels and shutdown or reboot system\\Weight 3}
\author[Geoff Robertson]{Angus Lees \texttt{gus@inodes.org} \and Geoffrey Robertson \texttt{ge@ffrey.com} \and Nick Urbanik \texttt{nicku@nicku.org}}
\subtitle{Linux Professional Institute Certification --- 102}


\begin{document}
\maketitle

\begin{frame}
  %% GENERATED SLIDE
  \frametitle{Description of Objective}
  \framesubtitle{1.106.2\ \ Change runlevels and shutdown or reboot system}
  \Large{}Candidates should be able to manage the runlevel of the
       system. This objective includes changing to single user mode, shutdown
       or rebooting the system. Candidates should be able to alert users before
       switching runlevel, and properly terminate processes. This objective
       also includes setting the default runlevel.

\end{frame}

\begin{frame}[fragile]
  %% GENERATED SLIDE
  \frametitle{Key files, terms, and utilities include:}
\begin{semiverbatim}\large
/etc/inittab
shutdown
init
\end{semiverbatim}
\end{frame}


\begin{frame}[fragile]

  \frametitle{Change runlevels and shutdown or reboot system}
  \framesubtitle{Objective}

  Candidates should be able to manage the runlevel of the system. This
  objective includes changing to single user mode, shutdown or
  rebooting the system. Candidates should be able to alert users before
  switching runlevel, and properly terminate processes. This objective
  also includes setting the default runlevel.

\end{frame}

\begin{frame}[fragile]

  \frametitle{Boot the system}
  \framesubtitle{Key files, terms, and utilities}

\begin{semiverbatim}
/etc/inittab
shutdown
init
\end{semiverbatim}
\end{frame}

\begin{frame}[fragile]

\frametitle{\texttt{/sbin/init}}

``init'' is the process started by the kernel after booting.  It is up
to \texttt{init} to start the rest of the system.  The usual ``SysV
init'' does this according to \texttt{/etc/inittab}.

The kernel also treats process ID 1 (init) specially:
\begin{itemize}
\item PID 1 is skipped by various ``kill all'' operations, etc
\item ``orphaned'' child processes are adopted by PID 1
\end{itemize}
\end{frame}

\begin{frame}[fragile]

\frametitle{Telling \texttt{init} what to do}

By sending signals directly (as root) or by running various commands,
which relay to \texttt{init}:

\begin{description}
\item[telinit] Tell \texttt{init} to reload inittab, re-exec itself or
switch runlevels

\item[shutdown] Initiate a shutdown by doing some book-keeping and
then signalling \texttt{init}

\item[halt, reboot, poweroff] Tools used to initiate or finalise
special kinds of shutdown

\item[runlevel] Find out current or previous runlevel
\end{description}
\end{frame}


\begin{frame}[fragile]

\frametitle{Runlevels}

The Linux Standards Base
  (\url{http://refspecs.freestandards.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/runlevels.html})
  defines the following standard runlevels that all distributions should
  follow to be compliant:

\begin{center}
  \noindent%
  \begin{tabular}[t]{ll}
    0 & halt\\
    1 & single user mode \\
    2 & multiuser with no network services exported \\
    3 & normal/full multiuser \\
    4 & reserved for local use, default is normal/full multiuser \\
    5 & multiuser with a display manager or equivalent \\
    6 & reboot
  \end{tabular}

% \begin{tabular}{cl}
% 0 & Halt \\
% 1 or S & ``Single user mode'' \\
% 2--5 & Normal multi-user runlevels \\
% 6 & Reboot \\
% \end{tabular}
\end{center}

Passed through via kernel command line, \texttt{telinit} or default in
\texttt{/etc/inittab}.

\end{frame}


\begin{frame}[fragile]

\frametitle{\texttt{/etc/inittab}}

\textit{id}~:~\textit{runlevels}~:~\textit{action}~:~\textit{process}

{\small
\begin{semiverbatim}
# /etc/inittab: init(8) configuration.

id:5:initdefault:

# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit

# /etc/init.d executes the S and K scripts
# scripts when change runlevel.
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
\end{semiverbatim}}
% # The default runlevel.
% id:2:initdefault:

% # Boot-time system configuration/initialisation script.
% # This is run first except when booting in emergency (-b) mode.
% si::sysinit:/etc/init.d/rcS

% # What to do in single-user mode.
% ~~:S:wait:/sbin/sulogin
\texttt{/etc/init.d/rc} runs all the ``K'' scripts in
\texttt{/etc/rc\textit{N}.d/}, followed by the ``S'' scripts.
\end{frame}


% \begin{frame}[fragile]

% \frametitle{\texttt{/etc/inittab}}

% {\small
% \begin{alltt}
% # /etc/init.d executes the S and K scripts upon change
% # of runlevel.

% l0:0:wait:/etc/init.d/rc 0
% l1:1:wait:/etc/init.d/rc 1
%  \vdots
% l6:6:wait:/etc/init.d/rc 6
% # Normally not reached, but fallthrough in case of emergency.
% z6:6:respawn:/sbin/sulogin
% \end{alltt}}

% \texttt{/etc/init.d/rc} runs all the ``K'' scripts in
% \texttt{/etc/rc\textit{N}.d/}, followed by the ``S'' scripts.
% \end{frame}

\begin{frame}[fragile]

\frametitle{\texttt{/etc/inittab}}

\begin{semiverbatim}\tiny
# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now

# When our UPS tells us power has
# failed, assume we have a few minutes 
# of power left.  Schedule a shutdown
# for 2 minutes from now.  
# This does, of course, assume you have
# powerd installed and your 
# UPS connected and working correctly.
 
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"

# If power was restored before the shutdown kicked in, cancel it.
pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"
\end{semiverbatim}
% # What to do when CTRL-ALT-DEL is pressed.
% ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

% # Action on special keypress (ALT-UpArrow).
% #kb::kbrequest:/bin/echo "Keyboard Request."

% # What to do when the power fails/returns.
% pf::powerwait:/etc/init.d/powerfail start
% pn::powerfailnow:/etc/init.d/powerfail now
% po::powerokwait:/etc/init.d/powerfail stop
\end{frame}

\begin{frame}[fragile]

\frametitle{\texttt{/etc/inittab}}

{\small
\begin{semiverbatim}
# Run gettys in standard runlevels
#co:2345:respawn:/sbin/agetty ttyS0 38400 vt100
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

# Run xdm in runlevel 5
x:5:once:/etc/X11/prefdm -nodaemon

#co:2345:respawn:/sbin/agetty ttyS0 38400 vt100
S1:2345:respawn:/sbin/mgetty ttyS1
\end{semiverbatim}}
% # /sbin/getty invocations for the runlevels.
% #
% # The "id" field MUST be the same as the last
% # characters of the device (after "tty").
% #
% # Note that on most Debian systems tty7 is used by the X Window System,
% # so if you want to add more getty's go ahead but skip tty7 if you run X.
% #
% 1:2345:respawn:/sbin/getty 38400 tty1
% 2:23:respawn:/sbin/getty 38400 tty2
%  \vdots
% 6:23:respawn:/sbin/getty 38400 tty6
\end{frame}

\begin{frame}[fragile]

\frametitle{\texttt{/etc/inittab}}

{\small
\begin{semiverbatim}
# Example how to put a getty on a serial line (for a terminal)
#
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100

# Example how to put a getty on a modem line.
#
#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3
\end{semiverbatim}}
\end{frame}

\begin{frame}[fragile]

\frametitle{Initiating a shutdown}

\texttt{shutdown \textit{[options]} \textit{time} \textit{[message]}}

Popular options:
\begin{description}
\item[-r] Reboot
\item[-h] Halt
\item[-c] Cancel a running shutdown
\end{description}

``time'' can be \textit{HH:MM} (eg~17:30) or +\textit{minutes} (eg~+5)
or ``now''

Examples:
\begin{semiverbatim}
shutdown -r now
shutdown -h 17:30 Scheduled hardware maintenance
\end{semiverbatim}

\end{frame}


\begin{frame}
  \frametitle{License Of This Document}
    Copyright \copyright\ 2005, 2003 Angus Lees <gus@inodes.org>, Geoffrey Robertson <ge@ffrey.com> and Nick Urbanik <nicku@nicku.org>. Permission is
    granted to make and distribute verbatim copies or modified
    versions of this document provided that this copyright notice and
    this permission notice are preserved on all copies under the terms
    of the GNU General Public License as published by the Free
    Software Foundation---either version 2 of the License or (at your
    option) any later version.

\end{frame}
\end{document}
