\documentclass[landscape]{slides}
\usepackage{graphicx}

\begin{document}

\begin{slide}
\begin{center}
{\large Startup Scripts}
\end{center}

\begin{itemize}
\item After single-user mode prompt, {\bf init} 
runs startup scripts.
\item Shell scripts to configure and initialize system services.
\item Sets name of computer.
\item sets timezone.
\item Check disks with {\bf fsck}.
\item Mounts systems disks.
\item Remove old files from {\bf /tmp}.
\item Configure network interfaces.
\item Start up daemons and network services.
\item Separate configuration files for scripts.
\end{itemize}

\end{slide}

\begin{slide}
\begin{center}
{\large Run Levels}
\end{center}

\begin{itemize}
\item {\bf init} defines 7 run levels.
\item 10 possible.
\begin{description}
\item[Level 0] Shut down.
\item[Level 1 or S] Single-user.
\item[Level 2-5] Multiuser levels.
\item[Level 6] Reboot.
\end{description}
\item Run Level 5 for X Windows.
\item Run Level 4 rarely used.
\item Can't remain in Levels 0 or 6.
\item Normal 2 or 3.
\item More than necessary.
\item Phone switch has 7 run levels?
\end{itemize}

\end{slide}

\begin{slide}
\begin{center}
{\large {\bf /etc/inittab}}
\end{center}

\begin{itemize}
\item Tells {\bf init} what do to at each run level.
\item Defines commands that are run when system enters
particular run level.
\item Default run level set there.
\item Progresses upward through run levels on boot.
\item Progresses down through run levels on shutdown.
\end{itemize}

\end{slide}

\begin{slide}
\begin{center}
{\large {\bf rc} directories}
\end{center}

\begin{itemize}
\item Change run level scripts.
\item {\bf /etc/init.d/rc}
\item Contains scripts that are called from {\bf inittab}.
\item These scripts execute other scripts from run-level-specific
directories ({\bf /etc/rc.d}).
\item Master copies of start-up scripts in {\bf /etc/init.d}.
\item Each script responsible for one daemon or service.
\item Arguments of {\bf start}, {\bf stop}, or {\bf restart}.
\item Manually start and stop by running scripts.
\end{itemize}

\end{slide}

\begin{slide}
\begin{center}
{\large Example}
\end{center}

\begin{verbatim}

#!/bin/bash
#
# Init file for OpenSSH server daemon
#
# chkconfig: 2345 55 25
# description: OpenSSH server daemon
#
# processname: sshd
# config: /etc/ssh/ssh_host_key
# config: /etc/ssh/ssh_host_key.pub
# config: /etc/ssh/ssh_random_seed
# config: /etc/ssh/sshd_config
# pidfile: /var/run/sshd.pid

# source function library
. /etc/rc.d/init.d/functions

# pull in sysconfig settings
[ -f /etc/sysconfig/sshd ] && . /etc/sysconfig/sshd

RETVAL=0
prog="sshd"

# Some functions to make the below more readable
KEYGEN=/usr/bin/ssh-keygen
SSHD=/usr/sbin/sshd
RSA1_KEY=/etc/ssh/ssh_host_key
RSA_KEY=/etc/ssh/ssh_host_rsa_key
DSA_KEY=/etc/ssh/ssh_host_dsa_key
PID_FILE=/var/run/sshd.pid

do_rsa1_keygen() {
	if [ ! -s $RSA1_KEY ]; then
		echo -n $"Generating SSH1 RSA host key: "
		if $KEYGEN -q -t rsa1 -f $RSA1_KEY -C '' -N '' >&/dev/null; then
			chmod 600 $RSA1_KEY
			chmod 644 $RSA1_KEY.pub
			success $"RSA1 key generation"
			echo
		else
			failure $"RSA1 key generation"
			echo
			exit 1
		fi
	fi
}

do_rsa_keygen() {
	if [ ! -s $RSA_KEY ]; then
		echo -n $"Generating SSH2 RSA host key: "
		if $KEYGEN -q -t rsa -f $RSA_KEY -C '' -N '' >&/dev/null; then
			chmod 600 $RSA_KEY
			chmod 644 $RSA_KEY.pub
			success $"RSA key generation"
			echo
		else
			failure $"RSA key generation"
			echo
			exit 1
		fi
	fi
}

do_dsa_keygen() {
	if [ ! -s $DSA_KEY ]; then
		echo -n $"Generating SSH2 DSA host key: "
		if $KEYGEN -q -t dsa -f $DSA_KEY -C '' -N '' >&/dev/null; then
			chmod 600 $DSA_KEY
			chmod 644 $DSA_KEY.pub
			success $"DSA key generation"
			echo
		else
			failure $"DSA key generation"
			echo
			exit 1
		fi
	fi
}

do_restart_sanity_check()
{
	$SSHD -t
	RETVAL=$?
	if [ ! "$RETVAL" = 0 ]; then
		failure $"Configuration file or keys are invalid"
		echo
	fi
}

start()
{
	# Create keys if necessary
	do_rsa1_keygen
	do_rsa_keygen
	do_dsa_keygen

	echo -n $"Starting $prog:"
	initlog -c "$SSHD $OPTIONS" && success || failure
	RETVAL=$?
	[ "$RETVAL" = 0 ] && touch /var/lock/subsys/sshd
	echo
}

stop()
{
	echo -n $"Stopping $prog:"
	killproc $SSHD -TERM
	RETVAL=$?
	[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/sshd
	echo
}

reload()
{
	echo -n $"Reloading $prog:"
	killproc $SSHD -HUP
	RETVAL=$?
	echo
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		stop
		start
		;;
	reload)
		reload
		;;
	condrestart)
		if [ -f /var/lock/subsys/sshd ] ; then
			do_restart_sanity_check
			if [ "$RETVAL" = 0 ] ; then
				stop
				# avoid race
				sleep 3
				start
			fi
		fi
		;;
	status)
		status $SSHD
		RETVAL=$?
		;;
	*)
		echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
		RETVAL=1
esac
exit $RETVAL

\end{verbatim}

\end{slide}


\begin{slide}
\begin{center}
{\large {\bf rc} directories}
\end{center}

\begin{itemize}
\item {\bf init} needs additional information about 
which scripts to run.
\item Looks in {\bf rc}{\sl level}{\bf .d}
\item They contain symbolic links to scripts in {\bf init.d}.
\item Symbolic links start with {\bf S} or {\bf R} followed
by number and name of service.
\item {\bf init} runs all the appropriate scripts when it makes
a transition for one run-level to another.
\item Place symbolic link in appropriate directory to add 
service or daemon.
\item {\bf ln -s /etc/init.d/sshd /etc/rc2.d/S99sshd}
\end{itemize}

\end{slide}

\begin{slide}
\begin{center}
{\large Redhat}
\end{center}

\begin{itemize}
\item {\bf rc.local} is last script run.
\item System specific infomation.
\item Overwritten at install.
\item {\bf chkconfig}: command line tool for
maintaining symbolic links in {\bf rc\#.d} directories.
\item Configuration files in {\bf /etc/sysconfig}.
\end{itemize}

\begin{tabular}{ll} \hline
File/Dir & Functions or Contents \\ \hline
{\bf apmd} & Lists arguments for Advanced Power Management Daemon \\
{\bf clock} & Type of clock\\
{\bf console} & always empty\\
{\bf hwconf} & Hardware info. used by kudzu.\\
{\bf i18n} & System local settings.\\
{\bf init} & Way messages from startup scripts displayed.\\
{\bf keyboard} & Sets keyboard type.\\
{\bf mouse} & Sets mouse type.\\
{\bf network} & Sets global network options.\\
{\bf network-scripts} & Accessory scripts and config files.\\ \hline
\end{tabular}

\end{slide}

\begin{slide}
\begin{center}
{\large {\bf /etc/inittab}}
\end{center}

\begin{itemize}
\item Lines as {\bf id:runlevels:action:process}
\item Empty and lines beginning with \# are ignored.
\item id: Identifies line in the file. Should be unique. For {\bf getty}
specifies terminal.
\item runlevels: Run levels line is considered for.
\item action: Action to take. {\bf respawn} to run command in next field
when it exits. {\bf once} to run once.
\item process: command to run.
\item  {\bf wait} run command once and wait for completion.
\end{itemize}

\end{slide}

\begin{slide}
\begin{center}
{\large Rebooting and Shutting Down}
\end{center}

\begin{itemize}
\item Reboot as last resort.
\item Linux filesystems buffer changes in memory and
write to disk only sporadically.
\item Faster but vulnerable to losing data.
\item UNIX sensitive to shutting down properly.
\end{itemize}

\end{slide}

\begin{slide}
\begin{center}
{\large {\bf shutdown}}
\end{center}

\begin{itemize}
\item safest, most considerate, and thorough
\item waits before shutting down, send message by {\bf wall}
to users.
\item {\bf -h} halt or {\bf -r} reboot
\item {\bf -F} fsck or {\bf f} not (default)
\item {\bf shutdown -h 09:30 "Going down for scheduled maintenance"}
\item {\bf shutdown -h +15 "Going down for scheduled maintenance"}
\end{itemize}

\end{slide}

\begin{slide}
\begin{center}
{\large {\bf halt}, {\bf reboot}, and {\bf telinit}}
\end{center}

\begin{itemize}
\item {\bf shutdown -h}: essential things to bring system down:
logs, kills processes, executes {\bf sync}, waits
for filesystem writes to complete, and halts kernel.
\item {\bf halt -n} prevents {\bf sync}
\item {\bf shutdown -r}: essential things to bring system down:
logs, kills processes, executes {\bf sync}, waits
for filesystem writes to complete, and halts kernel, reboots.
Also, supports {\bf -n} flag.
\item Change run-level. No warning message or grace period.
\end{itemize}

\end{slide}

\begin{slide}
\begin{center}
{\large Rootly Powers}
\end{center}

\begin{itemize}
\item System files and processes are owned by fictitious
user called ``root."
\item Owner can modify.
\item UID 0
\item Other users also, but bad idea.
\item root can change its UID and GID (example login)
\end{itemize}

\end{slide}

\begin{slide}
\begin{center}
{\large root}
\end{center}

\begin{itemize}
\item Change the root directory
\item create device files
\item set system clock
\item raise resource limits and process priorities
\item set systems hostname
\item configure network interfaces
\item open privileged ports ($<$ 1024)
\item shutdown system.
\item Choose good root password.
\item {\bf su} to root.
\end{itemize}

\end{slide}

\begin{slide}
\begin{center}
{\large Other Pseudo-Users}
\end{center}

\begin{description}
\item[bin] Legacy owner of system commands.
\item[daemon] Owner of unprivileged system software.
\item[nobody] Generic NFS user.
\end{description}

\end{slide}

\end{document}
