%% $Header: /cvsroot/lcdp/lpic/general-linux-1/notes.tex,v 1.7 2003/05/30 04:41:54 waratah Exp $

\documentclass[a4paper,10pt,fullpage]{book}

%\usepackage{draftcopy} 
\usepackage{palatino}
\usepackage{pifont}
\usepackage{pstricks}
\usepackage{graphicx}
\usepackage{alltt}
\usepackage{rotating}
\usepackage{rotate}
\usepackage{boxedminipage}
\setlength{\columnsep}{30mm}

%\title{ LPIC General Linux 1 }

\title{--- {\huge LPIC General Linux Part 1} ---
  \\[3mm]\Large{\textsf{(Study Notes)}    
    \footnote{Copyright \copyright 2002 Geoffrey Robertson. 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.}     
    \footnote{ {\scriptsize RCS Id = $ $Id: lpic.general-linux-1.notes.tex,v 1.2
        2002/02/28 23:06:04 geoffrey Exp geoffrey $ $} }}}

\author{geoffrey hector robertson \\geoffrey@zip.com.au}

%=============================================================================
\begin{document}%=============================================================
%=============================================================================





%----10->|-----20->|-----30->|-----40->|-----50->|-----60->|-----70->|-----80->

\maketitle

% \begin{abstract}
% The 
% \end{abstract}

% \begin{description}     
% \item[Document Description:] 
% \item[References:] \verb+ +
%   \begin{enumerate}
%   \item 
%   \end{enumerate}
% \item[Total Weighting:] 89 
% \end{description}

%\newpage
\tableofcontents
%\newpage


\noindent   

%=============================================================================
%=============================================================================
%=============================================================================
\part{Objectives} 

%=============================================================================
%=============================================================================
 \setcounter{chapter}{1}
% \chapter{Overview}


%=============================================================================
%=============================================================================
\chapter*{General Linux Part 1 [89]}
The information in this section is taken from the LPI Project
Objective Management System and is copyright to the Linux Professional
Institute. It should be noted that the latest version of this information will be found at:
\\ \textsf{http://www.lpi.org/cgi-bin/poms.py}.

\section*{A note about the numbering}
\begin{itemize}
\item The numbers hard on the left margin with one dot, e.g. 1.103,
  are LPI Exam Topic numbers.
\item The numbers in parentheses next to the LPI Exam Topic numbers
  are the old topic numbers and may be used to reference topics in
  older books and documentation.
\item The numbers hard on the left margin with two dots, e.g. 1.103.1,
  are LPI Exam Objectives.
\item The numbers in square brackets to the right of Topics and
  Objectives indicate weightings.
\end{itemize}


%=============================================================================
\setcounter{section}{102} 
\section{(1.3) GNU \& Unix Commands [30]} 

%------------------------------------------------------------------------------
\subsection{ Work on the command line [4]} 

\subsubsection*{Statement of Objective:}
 
Candidate should be able to Interact with shells and commands using
the command line. This includes typing valid commands and command
sequences, defining, referencing and exporting environment variables,
using command history and editing facilities, invoking commands in the
path and outside the path, using command substitution, applying
commands recursively through a directory tree and using man to find
out about commands.

\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
bash     echo  env   exec 
export   man   pwd   set    unset  
~/.bash_history      ~/.profile 
\end{alltt}

\subsubsection*{Resources of interest}
TBA

%------------------------------------------------------------------------------
\subsection{ Process text streams using filters [7]}
\subsubsection*{Statement of Objective:} 
Candidate should be able to apply filters to text streams. Tasks
include sending text files and output streams through text utility
filters to modify the output, and using standard UNIX commands found
in the GNU textutils package.

\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
cat    cut    expand   fmt     head
join   nl     od       paste   pr
sed    sort   split    tac     tail 
tr     uniq   wc       unexpand
\end{alltt}
\subsubsection*{Resources of interest}
TBA

%------------------------------------------------------------------------------
\subsection{ Perform basic file management [2]}
\subsubsection*{Statement of Objective:}
Candidate should be able to use the basic UNIX commands to copy, move,
and remove files and directories. Tasks include advanced file
management operations such as copying multiple files recursively,
removing directories recursively, and moving files that meet a
wildcard pattern. This includes using simple and advanced wildcard
specifications to refer to files, as well as using find to locate and
act on files based on type, size, or time.

\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
cp    find    mkdir    mv     ls 
rm    rmdir  touch    file    globbing 
\end{alltt}

\subsubsection*{Resources of Interest}
Manipulating Files: Tutorial from LinuxCommand.org 
Find Manpage

%------------------------------------------------------------------------------
\subsection{ Use streams, pipes, and redirects [3]}
\subsubsection*{Statement of Objective:}
Candidate should be able to redirect streams and connect them in order
to efficiently process textual data. Tasks include redirecting
standard input, standard output, and standard error, piping the output
of one command to the input of another command, using the output of
one command as arguments to another command and sending output to both
stdout and a file.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
tee   xargs   <    <<    >   >>   |  ` `\end{alltt}
 
\subsubsection*{Resources of Interest}
I/O Redirection: Tutorial from LinuxCommand.org\\ 
Tee Manpage


%------------------------------------------------------------------------------
\subsection{ Create, monitor, and kill processes [7]}
\subsubsection*{Statement of Objective:}
Candidate should be able to manage processes. This includes knowing
how to run jobs in the foreground and background, bring a job from the
background to the foreground and vice versa, start a process that will
run without being connected to a terminal and signal a program to
continue running after logout. Tasks also include monitoring active
processes, selecting and sorting processes for display, sending
signals to processes, killing processes and identifying and killing X
applications that did not terminate after the X session closed.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
\&    bg  fg  jobs  kill   nohup  ps  top 
\end{alltt} 

\subsubsection*{Resources of Interest}
Job Control: Tutorial from LinuxCommand.org 
ps Manpage 
kill Manpage 

%------------------------------------------------------------------------------
\subsection{ Modify process execution priorities [2]}
\subsubsection*{Statement of Objective:}
Candidate should be able to manage process execution priorities. Tasks
include running a program with higher or lower priority, determining
the priority of a process and changing the priority of a running
process.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
nice   ps   renice   top
\end{alltt} 

\subsubsection*{Resources of Interest}
nice Manpage 
renice Manpage 

%------------------------------------------------------------------------------
\subsection{ Search text files using regular expressions [3]}
\subsubsection*{Statement of Objective:}
The candidate should be able to manipulate files and text data using
regular expressions. This objective includes creating simple regular
expressions containing several notational elements. It also includes
using regular expression tools to perform searches through a
filesystem or file content.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
grep regexp sed
\end{alltt}

\subsubsection*{Resources of Interest}
Regular Expressions for Poets: Courtesy of RobotWisdom.com A Tao of
Regular Expressions: Courtesy of SiteScooper.org Capability Table:
Showing a table of RegExp symbols available for Grep, Egrep, Ed, Vi,
Sed, and Nawk.
 
%------------------------------------------------------------------------------
\subsection{ Perform basic file editing operations using vi [2]}

\subsubsection*{Statement of Objective:}
Candidate must be able to edit text files using vi. This objective
includes vi navigation, basic vi nodes, inserting, editing, deleting,
copying, and finding text.

\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
vi 
/    ?
h    j    k    l
G    H    L
i    c    d    dd    p    o    a
ZZ   :w!  :q!  :e!
:!
\end{alltt}
\subsubsection*{Resources of Interest} 
VI Lovers Home Page: Resource listing for using the vi text editor
\begin{alltt}
http://www.thomer.com/vi/vi.html
\end{alltt}

%------------------------------------------------------------------------------
%=============================================================================
\section{(2.4) Devices, Linux Filesystems, \& FHS [21]}

%------------------------------------------------------------------------------
\subsection{ Create partitions and filesystems [3]}
\subsubsection*{Statement of Objective:}
Candidates should be able to configure disk partitions and then create
filesystems on media such as hard disks. This objective includes using
various mkfs commands to set up partitions to various filesystems,
including ext2, ext3, reiserfs, vfat, and xfs.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
fdisk   mkfs
\end{alltt}
 
\subsubsection*{Resources of Interest:}
TBA

%------------------------------------------------------------------------------
\subsection{ Maintain the integrity of filesystems [5]}
\subsubsection*{Statement of Objective:}
Candidates should be able to verify the integrity of filesystems,
monitor free space and inodes, and repair simple filesystem problems.
This objective includes the commands required to maintain a standard
filesystem, as well as the extra data associated with a journaling
filesystem.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
du   df   fsck  e2fsck   mke2fs  
debugfs   dumpe2fs   tune2fs
\end{alltt}
 
\subsubsection*{Resources of Interest:}
TBA

%------------------------------------------------------------------------------
\subsection{ Control mounting and unmounting filesystems [3]}
\subsubsection*{Statement of Objective:}
Candidates should be able to configure the mounting of a filesystem.
This objective includes the ability to manually mount and unmount
filesystems, configure filesystem mounting on bootup, and configure
user mountable removable filesystems such as tape drives, floppies,
and CDs.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
/etc/fstab  mount  umount
\end{alltt}

\subsubsection*{Resources of Interest:}
TBA

%------------------------------------------------------------------------------
\subsection{ Managing disk quota [1]}
\subsubsection*{Statement of Objective:}
Candidates should be able to manage disk quotas for users. This
objective includes setting up a disk quota for a filesystem, editing,
checking, and generating user quota reports.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
quota   edquota   repquota   quotaon
\end{alltt}
 
\subsubsection*{Resources of Interest:}


http://www.linuxdoc.org/HOWTO/mini/Quota.html: The Quota mini-HOWTO 

%------------------------------------------------------------------------------
\subsection{ Use file permissions to control access to files [3]}
\subsubsection*{Statement of Objective:}
Candidates should be able to control file access through permissions.
This objective includes access permissions on regular and special
files as well as directories. Also included are access modes such as
suid, sgid, and the sticky bit, the use of the group field to grant
file access to workgroups, the immutable flag, and the default file
creation mode.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
chmod   umask   chattr
\end{alltt}

\subsubsection*{Resources of Interest:}
TBA

%------------------------------------------------------------------------------
\subsection{ Manage file ownership [2]}
\subsubsection*{Statement of Objective:}
Candidates should be able to control user and group ownership of
files. This objective includes the ability to change the user and
group owner of a file as well as the default group owner for new
files.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
chmod   chown   chgrp
\end{alltt}
 
\subsubsection*{Resources of Interest:}
TBA

%------------------------------------------------------------------------------
\subsection{ Create and change hard and symbolic links [2]}
\subsubsection*{Statement of Objective:}
Candidates should be able to create and manage hard and symbolic links
to a file. This objective includes the ability to create and identify
links, copy files through links, and use linked files to support
system administration tasks.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
ln 
\end{alltt}

\subsubsection*{Resources of Interest:}
TBA

%------------------------------------------------------------------------------
\subsection{ Find system files \& place files in the correct location [2]}
\subsubsection*{Statement of Objective:}
Candidates should be thoroughly familiar with the Filesystem
Hierarchy Standard, including typical file locations and directory
classifications. This objective includes the ability to find files and
commands on a Linux system.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
find   locate   slocate   updatedb
whereis   which   /etc/updatedb.conf
\end{alltt}

\subsubsection*{Resources of Interest:}
TBA


%------------------------------------------------------------------------------
%=============================================================================
\setcounter{section}{105}
\section{(2.6)Boot, Initialisation, Shutdown and  Runlevels [6]}

%------------------------------------------------------------------------------
\subsection{(3) Boot the system}
\subsubsection*{Statement of Objective:}
Candidates should be able to guide the system through the booting
process. This includes giving commands to the boot loader and giving
options to the kernel at boot time, and checking the events in the log
files.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
dmesg  /var/log/messages   
/etc/conf.modules or /etc/modules.conf 
LILO  GRUB
\end{alltt}

\subsubsection*{Resources of Interest:}
TBA

%------------------------------------------------------------------------------
\subsection{ Change runlevels and shutdown or reboot system [3]}
\subsubsection*{Statement of 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.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
shutdown  init  /etc/inittab 
\end{alltt}

\subsubsection*{Resources of Interest:}
TBA

%=============================================================================
\setcounter{section}{107}
\section{(1.8) Documentation [8]}

%------------------------------------------------------------------------------
\subsection{ Use and manage local system documentation [5]}
\subsubsection*{Statement of Objective:}
Candidates should be able to use and administer the man facility and
the material in \texttt{/usr/share/doc/}. This objective includes finding
relevant man pages, searching man page sections, finding commands and
man pages related to them, and configuring access to man sources and
the man system. It also includes using system documentation stored in
\texttt{/usr/share/doc/} and determining what documentation to keep in
\texttt{/usr/share/doc/}.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
man   apropos   whatis   MANPATH
\end{alltt}

\subsubsection*{Resources of Interest:}
TBA

%------------------------------------------------------------------------------
\subsection{ Find Linux documentation on the Internet [2]}
\subsubsection*{Statement of Objective:}
Candidates should be able to find and use Linux documentation. This
objective includes using Linux documentation at sources such as the
Linux Documentation Project (LDP), vendor and third-party websites,
newsgroups, newsgroup archives, and mailing lists.
\subsubsection*{Key files, terms, and utilities include:}
not applicable 
\subsubsection*{Resources of Interest:}
TBA

%------------------------------------------------------------------------------
\subsection{ Write System Documentation [1]}
\subsubsection*{Statement of Objective:}
Write documentation and maintain logs for local conventions,
procedures, configuration and configuration changes, file locations,
applications, and shell scripts.
\subsubsection*{Key files, terms, and utilities include:}
not applicable 
\subsubsection*{Resources of Interest:}
TBA
\subsubsection*{Note}
Difficult to test.


%=============================================================================
\setcounter{section}{110}
\section{(2.11) Administrative Tasks [24]} 

%------------------------------------------------------------------------------
\subsection{ Manage users and group accounts and related system files [7]}
\subsubsection*{Statement of Objective:}
Candidate should be able to add, remove, suspend and change user
accounts. Tasks include to add and remove groups, to change user/group
info in passwd/group databases. The objective also includes creating
special purpose and limited accounts.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
chageg passwd groupadd groupdel groupmod grpconv grpunconv passwd
pwconv pwunconv useradd userdel usermod /etc/passwd /etc/shadow
/etc/group /etc/gshadow
\end{alltt}

\subsubsection*{Resources of Interest:}
Chapter 9 - Managing User Accounts: The Linux System Administrators' Guide 

Manpages for useradd usermod userdel groupadd groupmod groupdel
useradd passwd chage

%------------------------------------------------------------------------------
\subsection{ Tune the user environment and system environment variables [4]}
\subsubsection*{Statement of Objective:}
Candidate should be able to modify global and user profiles. This
includes setting environment variables, maintaining skel directories
for new user accounts and setting command search path with the proper
directory.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
env export set unset /etc/profile /etc/skel
\end{alltt}

\subsubsection*{Resources of Interest:}
TBA

%------------------------------------------------------------------------------
\subsection{ Configure and use system log files to meet administrative and security needs [3]}
\subsubsection*{Statement of Objective:}
Candidate should be able to configure system logs. This objective
includes managing the type and level of information logged, manually
scanning log files for notable activity, monitoring log files,
arranging for automatic rotation and archiving of logs and tracking
down problems noted in logs.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
logrotate tail -f /etc/syslog.conf /var/log/*
\end{alltt}
 
\subsubsection*{Resources of Interest:}
TBA

%------------------------------------------------------------------------------
\subsection{ Automate system administration tasks by scheduling jobs to run in the future [4]}
\subsubsection*{Statement of Objective:}
Candidate should be able to use \texttt{cron} or \texttt{anacron} to
run jobs at regular intervals and to use at to run jobs at a specific
time. Task include managing cron and at jobs and configuring user
access to cron and at services.

 
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
at atq crontab /etc/anacrontab /etc/at.deny /etc/at.allow
  /etc/crontab /etc/cron.allow /etc/cron.deny /var/spool/cron/*
\end{alltt}
\subsubsection*{Resources of Interest:}
TBA


%------------------------------------------------------------------------------
\subsection{ Maintain an effective data backup strategy [3]}
\subsubsection*{Statement of Objective:}
Candidate should be able to plan a backup strategy and backup
filesystems automatically to various media. Tasks include dumping a
raw device to a file or vice versa, performing partial and manual
backups, verifying the integrity of backup files and partially or
fully restoring backups.
\subsubsection*{Key files, terms, and utilities include:}\texttt{}
\begin{alltt}
cpio dd dump restore tar
\end{alltt}
 
\subsubsection*{Resources of Interest:}
TBA


%------------------------------------------------------------------------------
\subsection{ Maintain system time [3]}
\subsubsection*{Statement of Objective:}
Candidate should be able to properly maintain the system time and
synchronise the clock over NTP. Tasks include setting the system date
and time, setting the BIOS clock to the correct time in UTC,
configuring the correct timezone for the system and configuring the
system to correct clock drift to match NTP clock.
\subsubsection*{Key files, terms, and utilities include:}
\begin{alltt}
date hwclock ntpd ntpdate /usr/share/zoneinfo /etc/timezone
/etc/localtime /etc/ntp.conf /etc/ntp.drift
\end{alltt}

\subsubsection*{Resources of Interest:}
TBA



%=============================================================================
%=============================================================================
%=============================================================================
\part{Resources}

%=============================================================================
%=============================================================================
\setcounter{chapter}{102}
\chapter{GNU \& Unix Commands} 

{\Large Old number: (1.3)}\\[2mm]
{\Large Weight: [30]}

\section*{Work on the command line [4]}
\section*{Process text  streams using filters [7]}
\section*{Perform basic file management [2]}
\section*{Use streams, pipes, and redirects [3]}
\section*{Create, monitor, and kill processes [7]}
\section*{Modify process execution priorities [2]}
\section*{Search text files using regular expressions [3]}
\section*{Perform basic file editing using vi [2]}

\newpage
%=============================================================================
\section{Work on the command line [4]}
\label{sec:103.1.re}

\newpage
%=============================================================================
\section{Process text  streams using filters [7]}
\label{sec:103.2.re}

%------------------------------------------------------------------------------
\subsection{Text Filter Exercise}
\label{sec:filter exercise}

%..............................................................................
\subsubsection{First catch some text}

Locate a section of text to practice filtering through various
filters. For example save the last 12 lines of the GPL license in a
temporary file. Edit the file with \texttt{vi} and add some tabs and
some extra blank lines.  Also duplicate a few lines. Add some 
carriage returns to the ends of a few lines (in vi do this in edit mode with 
a Cntl-v Cntl-m. They should show up as \^Ms in vi).

\begin{alltt}
\$ locate gpl-lic
/usr/share/doc/HTML/en/common/gpl-license
...
\$ tail -12 /usr/share/doc/HTML/en/common/gpl-license > \
/tmp/some.txt
\$ cd /tmp
\end{alltt}

%..............................................................................
\subsubsection{The file \texttt{some.txt}}

{\scriptsize
\begin{alltt}

  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  `Gnomovision' (which makes passes at compilers) written by James Hacker.

  <signature of Ty Coon>, 1 April 1989^M
  Ty Coon,       President        of       Vice^M


This General Public License does not permit incorporating your program into
This General Public License does not permit incorporating your program into
This General Public License does not permit incorporating your program into
This General Public License does not permit incorporating your program into



proprietary programs.  If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library.  If this is what you want to do, use the GNU Library General
Public License instead of this License.  
\end{alltt}
}

%..............................................................................
\subsubsection{\texttt{cat} the file}

Have a look at the man page for \texttt{cat}.

\begin{itemize}
\item Plain \texttt{cat} the file:

\begin{alltt}
\$ cat some.txt
\end{alltt}


\item \texttt{cat} the file with all lines numbered:
\begin{alltt}
\$ cat -n some.txt
\end{alltt}
\item \texttt{cat} the file with non-blank lines numbered:
\begin{alltt}
\$ cat -b some.txt
\end{alltt}
\item Check to see if there are any non printing characters:
\begin{alltt}
\$ cat -v some.txt
...
  <signature of Ty Coon>, 1 April 1989^M
...
\end{alltt}%
\item Display any tabs:
\begin{alltt}
\$ cat -T some.txt
...
  Ty Coon, ^IPresident ^Iof ^IVice
...
\end{alltt}
\item Do a \texttt{-vET} all at once:
\begin{alltt}
\$ cat -A some.txt
...
  <signature of Ty Coon>, 1 April 1989^M$
  Ty Coon, ^IPresident ^Iof ^IVice^M$
...
\end{alltt}
\item Strip out surplus blank lines:
\begin{alltt}
\$ cat -s some.txt
\end{alltt}
\end{itemize}

%..............................................................................
\subsubsection{\texttt{tac} the file}
Have a look at the man page for \texttt{tac}.

Try it out.

%..............................................................................
\subsubsection{Remove duplicate lines with \texttt{uniq}}

Have a look at the man page for \texttt{uniq}.

\begin{itemize}
\item Plain \texttt{uniq}
\begin{alltt}
\$ uniq some.txt
\end{alltt}
\item Show the repetition count: 
\begin{alltt}
\$ uniq -c some.txt
\end{alltt}
\item Print only the repeated lines:
\begin{alltt}
\$ uniq -dc some.txt
\end{alltt}
\end{itemize}


%..............................................................................
\subsubsection{Print lines from the beginning of a file with \texttt{head}}

Have a look at the man page for \texttt{head}.

Try it out on \texttt{gpl-license}.


%..............................................................................
\subsubsection{Print lines from the end of a file with \texttt{tail}}

Have a look at the man page for \texttt{tail}.
\begin{itemize}
 \item Try it out on \texttt{gpl-license}.
 \item Try the follow option:
\begin{alltt}
\$ tail -f /var/log/messages     
\end{alltt}
Create a message in another console to see it work.
\end{itemize}


%..............................................................................
\subsubsection{Isolate fields with \texttt{cut}}

Have a look at the man page for \texttt{cut}.

\begin{itemize}
\item Use cut to display only the \textsf{gecos} field and the shell field of the \texttt{passwd} file:
\begin{alltt}
\$ cut -d ":" -f5,7 /etc/passwd    
\end{alltt}
\end{itemize}


%..............................................................................
\subsubsection{Format the text with \texttt{fmt}}

Have a look at the man page for \texttt{fmt}.

\begin{alltt}
\$ fmt -w 50 some.txt

\$ fmt -t -w 60 some.txt
\end{alltt}


%..............................................................................
\subsubsection{merge lines of files using \texttt{paste}}

Have a look at the man page for \texttt{paste}.

Create two files and merge them.
\begin{alltt}
\$ cat > first
one
two
three
four
^D

\$ cat > second
this
that
these and
those

\$ paste first second
\end{alltt}






\newpage
%=============================================================================
\section{Perform basic file management [2]}
\label{sec:103.3.re}

\newpage
%=============================================================================
\section{Use streams, pipes, and redirects [3]}
\label{sec:103.4.re}

\newpage
%=============================================================================
\subsection{Create, monitor, and kill processes [7]}
\label{sec:103.5.re}

\newpage
%=============================================================================
\subsection{Modify process execution priorities [2]}
\label{sec:103.6.re}

\newpage
%=============================================================================
\section{Search text files using regular expressions [3]}
\label{sec:103.7.re}
 
Fun with Regular Expressions by Adrian J. Chung
\begin{alltt}
http://thelinuxgurus.org/regexp.html

\end{alltt}

\newpage
%------------------------------------------------------------------------------
\section{Perform basic file editing using vi [2]}
\label{sec:103.8.re}


%=============================================================================
%=============================================================================
\setcounter{chapter}{103} 
\chapter{Devices, Linux Filesystems \& FHS}
\label{ch:104.ex}

{\Large Old number: (2.4)}\\[2mm]
{\Large Weight: [21]}

\section*{Create partitions and filesystems [3]}
\section*{Maintain the integrity of filesystems [5]}
\section*{Control mounting and unmounting filesystems [3]}
\section*{Managing disk quota [1]}
\section*{Use file permissions to control access to files [3]}
\section*{Manage file ownership [2]}
\section*{Create and change hard and symbolic links [2]}
\section*{Find system files and place files in the correct location [2]}

\newpage
%=============================================================================
\section{Create partitions and filesystems [3]}
\label{sec:104.1.re}

\newpage
%=============================================================================
\section{Maintain the integrity of filesystems [5]}
\label{sec:104.2.re}

\newpage
%=============================================================================
\section{Control mounting and unmounting filesystems [3]}
\label{sec:104.3.re}

\newpage
%=============================================================================
\section{Managing disk quota [1]}
\label{sec:104.4.re}

\newpage
%=============================================================================
\section{Use file permissions to control access to files [3]}
\label{sec:104.5.re}


%------------------------------------------------------------------------------
\subsection{Ken Caldwell's Summary: Use file permissions to control access to files}
\label{sec:104.5.1.re}

Linux is a multi user operating system and therefore needs to provide a
system whereby the users can control access to their files.

All users are given a unique User IDentification number (UID) and are
assigned to at least one group(of users).  Each group is identified by
a Group IDentification number (GID).  Frequently users are assigned to
a group containing only one member (themselves) as their primary group.
The system administrator can add a user to other groups such as may be
convenient for example "sales", "engineering", "finance" or "management"

Not all "users" of the system are natural people others such as bin,
daemon, lp, fetchmail and nobody also exist.

About file access permissions

Any file created by a user will be owned by that user and belong to the
current group of that user.  That is to say the file will be tagged
with its creator's UID and GID.  The file will also be tagged with its
(default) permissions according to the umask of its creator.

The permissions pertaining to an ordinary file are the permission to
Read the file, the permission to edit or delete the file (Write) and
the permission to eXecute the file. These permissions are specified for:
1 The file's owner (ie the User who created the file)
2 Members of the Group associated with the file. (as determined by the
  GID)
3 all Others

Permissions are shown in the long format output of the ls command as a
nine character string such as, for example, rwxr-x--x.  The first three   
characters represent the permissions of the User who created the file.
In this case permission to Read, Write and eXecute the file. Members of
the Group have Read and eXecute permission while Others have only
eXecute permission.  Permissions can also be expressed as an octal
number with one digit for the user, one for the group and one for the
others.  Read permission is given a value of 4, write permission a
value of 2 and execute permission a value of 1.  In our previous
example the file could be described as having the permissions 751.

Permissions are interpreted slightly differently when applied to
directories.  The read permission is interpreted to mean the ability to
list the directory.  The write permission is interpreted to mean the
ability to write files to, or delete files from, the directory.  The
execute permission allows a user to cd to that directory or to include
it in a path to a directory to which you wish to change.

The initial permissions of a file upon creation are determined by
subtracting the user's umask from 777.  The default umask is usually
002 on systems where users have their own exclusive group or 022
otherwise.  In the former case files will be created with rwxrwxr-x
permissions and in the latter case rwxr-xr-x.

The permissions of a file may be altered by the file's owner by means
of the chmod command.  The chmod command is invoked as:

\$ chmod (required change) filename

The bit in brackets can be either the octal value of the new
permissions e.g. 644 or a string made up of three elements.  The first
element is one or more of u, g, o or a standing for User, Group, Others 
or All.  The second element is +, - or = meaning add the designated
access, remove the designated access or set exact access specified. The
third element is the access type ie one or more of r,w or x.

There are three further access modes which we haven't discussed so far.
They are SUID, SGID and the sticky bit.  These are also expressed as an
octal digit, 4 for SUID, 2 for SGID and 1 for the "sticky bit". Thus an
executable file which we have previously described as having
permissions 775 could more exactly be described as having permissions
0755.  If the file was SUID the description would be 4755.  Again the
meanings are different for ordinary files and directories.

An executable file with the SUID bit set runs with the UID of the file
owner instead of inheriting the UID of the parent process.  Similarly    
for the SGID bit.  The "sticky bit" has no meaning on Linux systems
when applied to ordinary files.  If the "sticky bit" is set on a
directory then only the owner of a file may delete it from that
directory even if the directory is world writable.  This is most often
seen on the /tmp directory.  If the SGID bit is set on a directory then
all files created in that directory will be assigned the GID of the   
directory rather than the GID of the user.  Another way of creating
files with a desired GID is to change the user's GID with the newgrp  
command.



\newpage
%=============================================================================
\section{Manage file ownership [2]}
\label{sec:104.6.re}


%------------------------------------------------------------------------------
\subsection{Ken Caldwell's Summary: Managing file ownership}
\label{sec:104.6.1.re}
The UID and/or the GID of a file may be changed by the file's owner
by means of the chown command.  man chown for all the options but
typically invoked as:

\$ chown newowner:newgroup filename

or:

\$ chown 314:42 filename

chgrp is similar but may only be used to change the group.

\newpage
%=============================================================================
\section{Create and change hard and symbolic links [2]}
\label{sec:104.7.re}

\newpage
%=============================================================================
\section{Find system files and place files in the correct location [2]}
\label{sec:104.8.re}

%------------------------------------------------------------------------------
\subsection{Ken Foskey's Summary: Using \texttt{find}}
\label{sec:104.8.1.re}

 :vi tw=72

 ...heading ...
 The find command.

 The find command is one of the fundamental tools of Unix.  It is a tool that is
 constantly rediscovered as you perform more and more complex operations with
 it.  The man page of this simple tool is 555 lines long.

 The most basic use of find is:

 find <directory> -name "$<$mask$>$" 

 To find a missing file somewhere in you home directory 

         find ~ -name missing.file 
 
 where ~ is shorthand for your home directory.   You can also use masks like
 "*.txt.gz" but you must put it in quotes.

 Why do you have to put it in quotes?

 ...pause for discussion from floor...

 When you use an * in a bash command line it is interpreted as a file
 expansion and it is looked for in the current directory and if it does
 exist it is substituted before the command is sent to find.  If it is
 not found then your shell may generate an error message (for example
 csh, I think).

  ... page ...

  According to the man page 'find - search for files in a directory
  hierarchy'  This is true but you can also find directories as well, like the
  filesystems .

  First we will start with some basic options:

  Doing options:
          -print  list the filename (default, never really use it).
          -exec   run a command
          -ok             run a command after prompting for confirmation.
          -ls             list file like `ls -dils`, is a lot of file information.

  Advanced doing options,  I am sure you will use these one day:

          -prune                  don't descend past this directory.
          -printf                 Print a filename based on format like C printf.
          -print0                 print but end with a null character.
          -fprintf <fn>   print a format string to a filename, (scripting??)
          -fprint <fn>    print filenames to a file.
          -fls <fn>               ls to a file


  Options on what entries we select:

          Most of these options take a number,  +number,  -number.  A little
          explanation is required first.

          picking one option,  -atime:

                  -atime 2                Will pick any file accessed two days ago.
                  -atime -2               Will pick any file access more than two days ago
                  -atime +2               Will pick any file accessed in the last day.

  ** file date and time

  Some basic stuff based on the file details itself.

          -atime n                files on access date
          -ctime n                files on creation date (note chmod mucks this up)
          -mtime n                files on modification date

          -anewer n               files on access date based on another file.
          -cnewer n               files on creation date based on another file.
          -newer n                files on modification date based on another file.

          example:  delete all files older than 7 days in the /data directory
          who have a .A extension.

%   .... pause to get suggestions from floor...
%   .... lecturers note solution is find /data -name "*.A" -ctime -7 -exec
%   rm {} \; ...

         Write the solution here.

 %%%%%        _______________________________________________________________


   A script may run a command and then 'touch' a tag file to give a
   timestamp when it was run.  assume that the last thing a script does is
   touch modification.tag in the /parms directory.  Write a command line
   that lists all details of files modified in the /apps/source/ directory based on this tag file.

  .... pause to get suggestions from floor...
  .... lecturers note solution is find /data -mnewer
  /parms/modification.tag -ls....

          Write solution here.


%          ----------------------------------------------------------------

  There is also a amin, cmin and mmin version of the above.


 ** Owner and group.

 One problem with the Unix authentification system, when you delete a
 userid you end up with magic numbers on a directory listing.  It is
 handy to be able to change the ownership on all files from the exiting
 staff member to the new person working on those projects.

         -nouser         users numeric id does not have and entry in /etc/passwd
         -nogroup        group numeric id does not have an entry in /etc/group
         -uid n          User by number
         -user name      User by name
         -gid n          Group by number
         -group name     Group by name


 I recently converted from Redhat to Debian.  I installed a new harddisk
 and mounted the old one as /mnt/old1.  I notice that when I do ls -al I
 get a username of 500 in the directory listing.  Change all the
 occurrences of 500 to the username of ken.

 .... lecturers note solution is AS ROOT
\begin{verbatim}
find /mnt/old1 -uid 500 -exec chown ken {} \;....
\end{verbatim}
         Write solution here

\hrule

 **  Inode number and links

 You have a directory listing,  the hard link count is greater than 1.
 ... lecturers note wait and ask class how we know this ....

 You have no idea where the other hard link is and you want to locate the
 other version to see what impact a change may have.

         -inode n

 ...  lecturers note,  I have no idea how to do this ....

 Write solution here

         -------------------------------------------------------
 
 
 Advanced options on what entries we select:

         -iregex         Use regex rather than standard file masks.
        


 Options on how we go through the directories:
         -xdev                   don't go into other file systems.
        

\newpage
%------------------------------------------------------------------------------
\subsection{Andrew Eager's Summary: Using \texttt{locate}, \texttt{updatedb} and \texttt{slocate}}
\label{sec:104.8.2.re}

SLOCATE - Secure Locate

LOCATE - Normal Locate  (Normally symlinked to slocate)

Slocate is used to find files on the system without actually having to
search the entire directory tree.  A database of all files on the
system is created and is then used by slocate to reveal the files
actual location.  It is important to note that slocate may return a
result which is no longer valid since the directory structure may have
been modified since the slocate database was last created.  For
example, you create a file called poobar.txt, create the slocate
database and then remove poobar.txt.  Slocate will still return
poobar.txt?s original location until the slocate database is
recreated.


 Slocate can be used in two modes:
 \begin{itemize}
   \item Search mode:-  To locate an actual file within the database
   \item Database creation mode:- To build the database
 \end{itemize}


\subsubsection{Search usage:}
\begin{alltt}
 slocate [-qi] [-d <path>] [-r <regexp>] <search string>... 
\end{alltt}
\begin{description}
  \item[\texttt{-q}] Quiet mode.  Suppress error messages.
  \item[\texttt{-i}] \underline{Does a case insensitive search.}
  \item[\texttt{-d}] \underline{Specify a database to use.}
  \item[\texttt{-r}] Pass a regular expression instead of a search string.
\end{description}


\subsubsection{Examples:}
\begin{description}
  \item[\texttt{locate ls}] 
\begin{alltt}
\$ locate ls \(\hookleftarrow\)
...
 /etc/X11/xkb/symbols/xfree68/ataritt
/etc/X11/xkb/symbols/xfree68/amiga
/etc/alternatives/tclsh
...   
\end{alltt}
  \item[\texttt{locate -r "/ls\$"}] 
\begin{alltt}
\$ locate -r "/ls\$" \(\hookleftarrow\)
/home/geoffrey/tafe/mos/compress/ls
/usr/lib/bitchx/help/8_Scripts/ls
/bin/ls 
\end{alltt} 
\end{description} 
The above example illustrates the need for a \textsf{regex} option to \texttt{locate}.
In the first example there will be lots of hits.  In the second there
is only one (the actual \texttt{ls} command).

As well as searching for a file in the database, \texttt{locate} can also
build the search database.
 
\subsubsection{Database Creation Usage:}

As well as searching for a file in the database, slocate can also
build the search database.
\begin{description}
  \item[\texttt{-u}] \underline{Create slocate database starting at
    path \texttt{/}.}
  \item[\texttt{-U $<$dir$>$}] \underline{Create slocate database
    starting at path $<dir>$.}
  \item[\texttt{-c}] \underline{Parse original GNU Locate's
    \texttt{/etc/updatedb.conf}}
  \item[\texttt{-e $<$dir1...$>$}] \underline{Exclude directories from
    the slocate database when using the -u or -U options.}
  \item[\texttt{-f $<$fs...$>$}] Exclude file system types from the
  slocate database
  \item[-l] Security level. 0--$>$ security off, 1--$>$ security on
  \item[\texttt{-q}] Quiet mode.  Error messages are suppressed.
  \item[\texttt{-o $<$file$>$}] \underline{Specify the name of the
    database file to create}
  \item[\texttt{-v}] Be verbose 
\end{description}


\subsubsection{Examples}
\begin{itemize}
  \item Create a database for all directories under \texttt{/usr} and
  place the resulting database file into \texttt{slocate.db} in andy's
  home directory.
\begin{alltt}
\# slocate -U /usr -o /home/andy/slocate.db  \(\hookleftarrow\)
\end{alltt}
  \item Create a database for all directories under /usr, excluding
  directories under /usr/man and place the resulting database file
  into slocate.db in andy?s home directory.
\begin{alltt}
\# slocate  -U /usr   -e /usr/man  -o /home/andy/slocate.db \(\hookleftarrow\)
\end{alltt}
\end{itemize}


\subsubsection{Update \texttt{slocate} database---\texttt{update}}

\texttt{updatedb} is simply a link to slocate that implies the -u option.
(Excerpt from the man page:- man updatedb)

\small
\begin{alltt}
\$ ls -l `which updatedb` \(\hookleftarrow\)
lrwxrwxrwx  1 root  root 7 Mar 27 10:44 /usr/bin/updatedb -> slocate*
\end{alltt}
\normalsize

\texttt{updatedb} is typically executed periodically via \textsf{cron}.


\subsubsection{\texttt{/etc/updatedb.conf}}

\begin{itemize} 
  \item The \texttt{updatedb} (or \texttt{slocate}) tool can use a
  configuration file to decide which directories and file systems
  are included when the database is created.  This file is normally
  located in \texttt{/etc/updatedb.conf}
  
  \item The following is a list of keywords that are recognised by
  updatedb (slocate) and their equivalent command line options
  \begin{description}
    \item[\texttt{PRUNEFS}] \texttt{$<$fs\_type1 fs\_type2...$>$} -
    Option \texttt{-f}
    \item[\texttt{PRUNEPATHS}] \texttt{$<$dir1 dir2 dir3...$>$} - Opion
    \texttt{-e}
  \end{description}
  \item Example \texttt{updatedb.conf}
\begin{alltt}
PRUNEFS="devpts NFS nfs afs proc smbfs autofs auto iso9660"
PRUNEPATHS="/tmp /usr/tmp /var/tmp /afs /net? 
export PRUNEFS
export PRUNEPATHS
\end{alltt}
\end{itemize}

\subsubsection{\texttt{slocate} Exercises}

\begin{enumerate}
  \item Create an \texttt{slocate} database in your home directory including all directories from \texttt{/} down.
  \item Using the database created in step 1, locate all files with \texttt{rm} in the filename
  \item Using the database created in step 1, locate the executable file \texttt{rm} using a regex.  (ie  \texttt{/some/path/rm})
  \item Create an slocate database in your home directory include all directories from \texttt{/} down but excluding the \texttt{/bin} directory.
  \item Repeat (2) and (3) above.  Do you notice anything different ?
  \item After backing up your existing \texttt{/etc/updatedb.conf}, say
\begin{alltt}
\# cp /etc/updatedb.conf /etc/updatedb.conf.orig \(\hookleftarrow\)   
\end{alltt}
edit \texttt{/etc/updatedb.conf} to perform the same actions as in step (4).
  \item When you have finished this exercise restore your original  \texttt{/etc/updatedb.conf}.
\end{enumerate}

%=============================================================================
%=============================================================================
\setcounter{chapter}{110}
\chapter{Administrative Tasks}
\label{ch:111.ex}


%=============================================================================
\setcounter{section}{4}
\section{Maintain an effective data backup strategy [3]}

%------------------------------------------------------------------------------

\subsection{Backup Overview}
Prepared by Grant Parnell
\bigskip

Decide what data is important and how long you can do without it.

\begin{itemize}
\item Is this used 24 x 7 or just business hours?
\item During business hours how long can you 
do without it? 4 hours, 30 minutes, 5 minutes?
\item  How up-to-date is it 
required to get you running in an emergency?
\item Are you backing up for 
archival or high availability or espionage?
\end{itemize} 


%------------------------------------------------------------------------------
\subsubsection{Examples of Data}

\begin{description}

\item[Static:] Configurations of running servers. You need these 24x7 but they 
don't change much.

\item[Databases / Transactions - financial \& otherwise:]
These are updated
frequently and need to balance. Associated with these are logs and
duplication and other means of rollback and integrity checking. With databases 
it's often a good idea to dump them in a good portable format, especially 
if the inbuilt format is not cross platform or cross version compatible. 
EG 'mysqldump mydata >mydata.dump' will give you a text file which can be 
used on most mysql versions and possibly adapted to other database 
packages.

\item[Logs:] People don't tend to read them unless something goes wrong in which 
case they're valuable. These need to be kept but don't need to be restored 
in a hurry.

\item[Home directories:]
This is a mixed bag of everything but some policies 
could be instated to make the admin's life easier. EG Making specific 
sub-directories for things and assigning them different backup/restore 
priorities. Often the existence of a home directory is more important than 
the rest of the contents as it may make a user unable to login without it.

\item[Code repositories:]
Programmers should be accustomed to doing regular 
backups anyway, they often need to revert to an old version to figure out 
what they broke. Any tools used such as CVS that have a central repository 
should be backed up almost as often as programmers commit code, at least 
once a day but they could probably cope with it being missing for half a 
day.

\item[High availability - read only:]
Websites frequently used by your clients. 
They can contain dynamic data but customers don't update it. This sort of 
scenario lends itself to frequent replication to a backup server.

\item[High availability - interactive:]
Taking a website again, this one might 
allow the customer to do such things as place orders. The website 
maintains some state information to allow building of an order. This is 
the most difficult, the state information can be stored in a replicated 
database. In the event of web server failure the other one comes into play 
and the customer may have to login again but the information is kept. 
(Otherwise complex designs and expensive hardware can be used to 
seamlessly migrate the state to the other webserver).

\end{description} 

%------------------------------------------------------------------------------
\subsubsection{Important Linux directories}

\footnotesize

\begin{verbatim}
/var/spool/mail   - daily backup
/var/lib/mysql    - databases - backup the dumps, and possibly 
                    the binary.
/var/log ?        - from "don't care" to "backup daily"
/etc              - backup config changes
/home             - be selective, but if you can't backup daily.
/home/<user>/mail - contains the user's mail folders 
                    (may also be 'Mail' or 'Maildir')
/home/<user>/.ssh - If you login using ssh keys only, this is a 
                    must have.
/usr/local        - locally installed apps & data 
                    Application specifics
\end{verbatim} 
\normalsize


%------------------------------------------------------------------------------
\subsection{Backup \& Restore methods}

%------------------------------------------------------------------------------
\subsubsection{Copy the files to another directory}

This is the poor mans backup and does not offer much peace of mind. It 
does protect against accidental deletion and corruption by users. One 
advantage is that it can be very quick for things such as log files. 
You can also keep multiple copies, one for every day of the week for 
example. See /etc/logrotate.conf.


%------------------------------------------------------------------------------
\subsubsection{Backup to a standby partition}

This has about the same level of peace of mind as the above. The backup 
partition can be left un-mounted after the backup. The backup is slower 
than the above but the restore operation can be quick. See also "Broken 
Mirror" method below.


%------------------------------------------------------------------------------
\subsubsection{Backup to tape}

This is probably the most common backup used in the commercial world. It's 
easy to backup the lot every day provided you have the tape capacity. If 
you don't, you become more selective as to what to backup. There's a 
variety of software to do this but there's 3 main basic systems. Tar, cpio 
and dump. Often commercial software uses these basic systems and provide 
for labelling and indexing as well as multi-server capability from a simple 
GUI. The reason for using the basic systems is you can restore from them 
if you have to.

%------------------------------------------------------------------------------
\subsubsection{Backup to standby disk}

This can offer peace of mind and a fairly cheap backup for people that 
don't require 24x7 service. Basically a removable drive bay houses another 
hard disk of similar capacity and the entire system is backed up. This can 
be done partition by partition or file by file using dd, cpio or rsync. 
Additional steps can be taken to ensure that the backup is also bootable. 
The backup drive should be removed once done and treated like a tape. The 
disadvantage here is that you most likely will need to power down the 
system twice for one backup. Alternately, if you have an external USB or 
fire-wire storage medium it becomes possible to do this without downtime.

%------------------------------------------------------------------------------
\subsubsection{Backup to CDROM/DVD}

Under Linux (as far as I know) there's no software to directly write data 
without creating an image first. This means there must be sufficient space 
available. It would be possible to create a bootable CD with restore 
software and a compressed filesystem but I haven't seen this. It may be OK 
if you don't have a large filesystem or you have a DVD writer or you're 
not backing up everything.

%------------------------------------------------------------------------------
\subsubsection{RAID System}

Not strictly a backup but a RAID system can protect against hard drive
failure by providing redundancy. Data is written simultaneously to 2 or
more hard drives and can include parity information. It does not protect
against corrupt databases and people removing files. It will corrupt and
remove files equally well on all disks. Linux can do RAID in software 
very well but the ideal is a hardware solution involving hot swapable 
disks so they can be replaced while the system is fully running. A RAID 
system can mean the difference between going on-site at 3am and saying "Oh 
dear, we'll replace that first thing in the morning". Just ensure that you 
do have a replacement readily available and do not have to wait a week.



%------------------------------------------------------------------------------
\subsubsection{RAID Tape array}

In a similar manner to RAID 5 disks, data is written in parallel to 5 
tape drives which increases throughput and data integrity.

%------------------------------------------------------------------------------
\subsubsection{Backup Server}

All of the methods discussed so far involve direct transfer from server to 
backup medium. If you have a number of servers it may not be practical to 
install backup devices on each. Another way is to remotely access the 
required medium directly (/dev/rmt0) but arbitration of access can be an 
issue. An increasingly popular way is to provide a super-server with a 
huge amount of disk space capable of holding everything required by the 
other servers. Transferring the data can happen at any time in either a 
batch or continuous process. A batch would be say backup a whole directory 
at once whereas a continuous operation might be transmitting log 
information or database updates. The backup server itself may then employ 
any one or more methods to perform backups of itself, possibly based on 
some statistical analysis. An example of this is a system called ADSM 
which employs RAID arrays, multiple tape drives, a tape robot with barcode 
reader and intelligent software that tells the operators which tapes are 
to go off-site and which ones it wants back. It essentially is a huge 
cache that stores frequently changing data locally and stores old data 
off-site.

%------------------------------------------------------------------------------
\subsubsection{Broken Mirror}

If you've got about 100Gb of data on a mirrored pair of disks and only 
have a 10 minute backup window this may be for you. Basically you bring 
the system down, unhook one of the mirrors and replace it with another set 
of drives and bring the system up again. Mirroring starts from scratch 
during quiet time and should be finished before load picks up again. With 
the drive set you just un-hooked this can then be loaded into the standby 
server and backed up to tape over the course of many hours.
Some high end servers can perform this operation without downtime as the 
hooking up can be done using inbuilt hardware or such things as dual-port 
fire-wire drive bays. All that is required in this case is an application 
shutdown, sync, dismount, remount, application start type operation.



%==============================================================================
\subsection{Software}
dd - can be used to copy raw disk blocks, even to tape (yuk). 
eg dd if=/dev/hda1 of=/dev/hdb1

tar - Tape ARchive - you all know how to unpack tgz files, and maybe even 
create them. Just remove the 'f' option. It also can be an advantage not 
to use compression as some drives have this built in. Also, a portion of 
the tape being corrupt can ruin the rest of the data, whereas you can skip 
corrupt bits and pickup the next file if not compressed.
eg tar -c /home 
cd /tmp; tar -x 

cpio - cp I/O - Similar capabilities of tar but different methodology.
EG find /home | cpio -oB >/dev/tape
cd /tmp; cpio -idB </dev/tape

rsync - remote sync - can sync a directory or whole filesystem by only 
transferring the changes between them. Be careful about trailing slashes.
rsync -a /home /backup/
rsync -a -e ssh /home backup@backup:/serverA/

Arkeia - commercial package
BRU - commercial package
Amanda - Open source?
Thousands more, some are client/server model and can backup multiple 
operating systems which is great.

See http://www.linuxhelp.com.au/free.shtml for our generic CPIO backup 
script.


%==============================================================================
\subsection{Rotation \& off-site strategies}
It's no good having a backup if it's sitting next to the computer when 
there's a fire. You've got to have some off-site backups for really 
important stuff. On a small scale a friend of mine has a backup of all my 
music CD's I couldn't live without.

You could use this example strategy with any bulk medium but typically
people refer to tapes or a set of tapes and for convenience I'll refer to
a tape.  If you can fit everything on one tape good for you, life is 
easy, backup the lot daily. If you don't you'll have to do an incremental 
backup (ie what's changed) daily and do a whole backup with multiple tapes 
weekly. Take the weekly backup off-site home from work or over to a 
trustworthy friend's place. Once a month take a weekly backup to long 
term storage and keep it for 7 years or something if it's got all your tax 
info on it. It goes without saying the tapes should be labelled 
full/incremental and a date, hostname and what sequence in the set they 
are. Daily backup tapes may be rotated once a week with a new tape 
supplied once a week for a specific day of the week. Eg week1 will be all 
new tapes with one shipped off on Monday morning. week2 it'll be a new 
tape for Sunday morning, week3 it'll be Saturday mornings tape that's 
new. Alternately, some people believe the weekly or monthly should be on a 
fresh tape that's never been used.

With this strategy you get reasonable rotation of the tapes keeping costs 
down and for archival purposes, if you keep at least a months worth of 
data on the server you'll be able to go back to any point over the last 
few years and pull out a file. If you keep at least 3 months on hard disk 
you'll have 3 copies of this on 3 separate tapes because believe it or not 
they do fail and it will happen to you. To explain this more fully lets 
look at the following table and assume we have some wages data every week 
and the company's just started and there's 4 weeks per month.

{\scriptsize
\begin{verbatim}
server has      weekly tape has         monthly tape has
wk1     wk1             wk1                     -
wk2     wk1-2           wk1-2                   -
wk3     wk1-3           wk1-3                   -
wk4     wk1-4           wk1-4,month1            wk1-4,month1
wk5     wk1-5           wk1-5,month1            -
wk6     wk1-6           wk1-6,month1            -
wk7     wk1-7           wk1-7,month1            -
wk8     wk1-8           wk1-8,month1-2          wk1-8,month1-2
wk9     wk1-9           wk1-9,month1-2          -
wk10    wk1-10          wk1-10,month1-2         -
wk11    wk1-11          wk1-11,month1-2         -
wk12    wk1-12          wk1-12,month1-3         wk1-12,month1-3
wk13    wk2-13          wk2-13,month1-3         -
wk14    wk3-14          wk3-14,month1-3         -
wk15    wk4-15          wk4-15,month1-3         -
wk16    wk5-16          wk5-16,month2-4         wk5-16,month2-4
wk17    wk6-17          wk6-17,month2-4         -
wk18    wk7-18          wk7-18,month2-4         -
wk19    wk8-19          wk8-19,month2-4         -
wk20    wk9-20          wk9-20,month3-5         wk9-20,month3-5
wk21    wk10-21         wk10-21,month3-5        -
....
\end{verbatim}
}

A complete backup and archive strategy should provide a means of going 
back to any point in time for critical data. Sometimes keeping the whole 
lot of data is not required. For example you could drop the weekly 
information and keep the monthly summary information and do a dedicated 
monthly backup for this data. The monthly data may be optimised and 
arranged for searching and an index provided but essentially contain all 
the information from the weekly data.





%=============================================================================
%=============================================================================
%=============================================================================
\part{Practical Exercises}

%=============================================================================
%=============================================================================
\setcounter{chapter}{102}
\chapter{GNU \& Unix Commands}

{\Large Old number: (1.3)}\\[2mm]
{\Large Weight: [30]}

\section*{Work on the command line [4]}
\section*{Process text  streams using filters [7]}
\section*{Perform basic file management [2]}
\section*{Use streams, pipes, and redirects [3]}
\section*{Create, monitor, and kill processes [7]}
\section*{Modify process execution priorities [2]}
\section*{Search text files using regular expressions [3]}
\section*{Perform basic file editing using vi [2]}


\newpage
%=============================================================================
\section{Work on the command line [4]}
\label{sec:103.1.ex}

\newpage
%=============================================================================

\section{Process text  streams using filters [7]}
\label{sec:103.2.ex}
\newpage
%=============================================================================
\section{Perform basic file management [2]}
\label{sec:103.3.ex}

\newpage
%=============================================================================
\section{Use streams, pipes, and redirects [3]}
\label{sec:103.4.ex}

\newpage
%=============================================================================
\section{Create, monitor, and kill processes [7]}
\label{sec:103.5.ex}

\newpage
%=============================================================================
\section{Modify process execution priorities [2]}
\label{sec:103.6.ex}

\begin{enumerate}
\item This exercise requires a few example processes to play around with, so first we will create a few.
  \begin{itemize}
  \item Using the \texttt{vi} editor (for practice) make a file called
    \texttt{a.c}.
    \begin{itemize}
    \item Do not use the arrow keys---use h, j, k and l.
    \item Do not use the \textsf{Backspace} or \textsf{Delete}
      keys---use \texttt{x}.
    \item Be sure you are familiar with the use of \texttt{i},
      \texttt{a}, \texttt{o} and \texttt{O} for entering new text.
    \item For saving and quitting use each of \texttt{ZZ}, \texttt{:w},
      \texttt{q:} and \texttt{!}.
    \item Delete, Yank and Put with \texttt{dd}, \texttt{yy} and \texttt{p}.
    \item Use \texttt{u} to undo, numerical modifiers (e.g. 5dd) and
      \texttt{.} to repeat.
    \end{itemize}
  \item The file should contain this text:
\begin{verbatim}
#include <stdio.h>
 
int main()
{
  int i = 0;

  while (1) {
    system("clear");
    printf("Process a: %d\n", i);
    ++i;
  }

  return 0;
}
\end{verbatim}
  \item Copy the file \texttt{a.c} to \texttt{b.c} and \texttt{c.c}.
\begin{alltt}
\$ cp a.c {b,c}.c \(\hookleftarrow\)    
\end{alltt}
  \item Edit the \texttt{printf()} calls in files \texttt{b.c} and
    \texttt{c.c} to refer to \texttt{Process b:} and \texttt{Process c:}
    respectively.
  \item Compile the programs:
\begin{alltt}
\$ gcc a.c -o a; gcc b.c -o b; gcc c.c -o c \(\hookleftarrow\)    
\end{alltt}
\end{itemize}

\item Test your three programs.
\begin{itemize}
\item Start a program running in the background:
\begin{alltt}
\$ ./a \(\hookleftarrow\) 
 Process a: 400   
\end{alltt}
\item Suspend the program:
\begin{alltt}
^z
[1]+  Stopped                 ./a   
\end{alltt}
\item Kill the job:
\begin{alltt}
\$ kill %1 \(\hookleftarrow\)   
\end{alltt}
\end{itemize}

\item Use \texttt{ps} to view the processes.
\begin{itemize}
\item Run the processes in the background with differing degrees of niceness:
\begin{alltt}
  \$ ./a& nice ./b& nice -19 ./c& \(\hookleftarrow\)      
\end{alltt}
\item Glance at and absorb the manpage for \texttt{ps}. Note well that some options are preceded by a minus(-) and others are not. For example \texttt{ps a} and \texttt{ps -a} do different things.
\item Locate the processes using the \texttt{ps} command; try the \texttt{a}, \texttt{u}, \texttt{x}, and \texttt{f} options separately and in combinations. e.g.:
\begin{alltt}
\$ ps aux |grep "./a " \(\hookleftarrow\)   
\end{alltt}
\item Kill and restart one of the processes (use the PID not ``123456'':
\begin{alltt}
\$ kill 123456  \(\hookleftarrow\)
\$ ps aux |grep "./a " \(\hookleftarrow\)
\$ ./a&
\$ ps aux |grep "./a " \(\hookleftarrow\)   
\end{alltt}
\end{itemize}

\item Use \texttt{top} to view and modify the processes.
  \begin{itemize}
\item Run \texttt{top} in the foreground:
 \begin{alltt}
\$ top \(\hookleftarrow\)    
\end{alltt}  
\item Look at the \texttt{top} help: Press \textsf{h}
\item Sort by accumulated time: Press \texttt{T}
\item Re-nice a process (Note: Users may only monotonically increase the niceness processes, and (\&\&) they must own the process.): 
  \begin{itemize}
  \item Press \textsf{r}
  \item PID to renice: 1234567890 \(\hookleftarrow\)
  \item Renice PID 1973 to value: 5  \(\hookleftarrow\)
  \end{itemize}
  \end{itemize}
\item Reniceing from the command line:
  \begin{itemize}
  \item After finding it's \textsf{PID}\texttt{renice} one of your processes:
\begin{alltt}
\$ ps aux |grep "./c " \(\hookleftarrow\) 
\$ renice +15 1234567890      
\end{alltt}
\item Re-nice negatively---notice that only the superuser may reduce the niceness of a process.
\begin{alltt}
\$ renice -10 1234567890 \(\hookleftarrow\) 
renice: 1234567890: setpriority: Permission denied
\$ su -c 'renice -10 1234567890' \(\hookleftarrow\)  
  \end{alltt}
  \end{itemize}
\item Kill off \texttt{./a}, \texttt{./b} and \texttt{./c}.
\end{enumerate}


\newpage
%------------------------------------------------------------------------------
\section{Search text files using regular expressions [3]}
\label{sec:103.7.ex}

  
\newpage
%------------------------------------------------------------------------------
\section{Perform basic file editing using vi [2]}
\label{sec:103.8.ex}

%------------------------------------------------------------------------------
\subsection{Introduction to \texttt{vi}}
\label{sec:103.8.ex}


%------------------------------------------------------------------------------
\subsubsection{Note}
Should you need a good sized text file to practice editing on, you
will almost certainly find a copy of the GPL License on your system.
Be sure to deconsecrate the file by renaming before munging it. You
may locate one thus:
\begin{alltt}
\$ locate GPL \(\hookleftarrow\)
...
/usr/share/doc/netpbm-9.14/GPL_LICENSE.txt
/usr/share/doc/cdda2wav-1.10/GPL
/usr/share/doc/cdparanoia-alpha9.8/GPL
/usr/share/doc/stunnel-3.19/COPYRIGHT.GPL
/usr/share/doc/libesmtp-0.8.4/COPYING.GPL
...
\end{alltt}
Make a scratch copy at a suitable location and open it for editing:
\begin{alltt}
\$ cp /usr/share/doc/stunnel-3.19/COPYRIGHT.GPL \ \(\hookleftarrow\)
/tmp/munged_gpl.txt \(\hookleftarrow\)
\$ vi /tmp/munged_gpl.txt \(\hookleftarrow\)
\end{alltt}

%------------------------------------------------------------------------------
\subsection{Vi tour}
\label{sec:1.103.8.ex}
% This exercise was written by Ken Foley

%------------------------------------------------------------------------------
\subsubsection{vi}

Vi is the Unix editor, simply it is available on just about every Unix installation by default. This is the reason that you have to have a minimum of basic vi skills to allow you to change files when you favourite editor is not available, boot disks have vi due to lack of space.

Please note that there are many implementations of vi, the baseline is a very crude editor. This extends to a very extended and powerful VIM editor available on most platforms. I use vim because I am restricted to vi on many of the Unix systems I support, rather than trying to 'switch editors' mentally I have vi on every platform I use, including Windows.
 
%------------------------------------------------------------------------------
\subsubsection{vi is a mode editor}

Vi is an editor and it is definitely not a friendly editing environment. In fact a random typing of keys of the keyboard can render your text totally unreadable. Vi has been around a long time it was created in an era where editors were modal. The editor can be in three different unrelated states described below.

\begin{description}
\item[Input mode] This is the mode where you simply type. You characters appear in the text file as you type.
\item[Command mode] This is where character take on special significance, for example 'i' for insert 'D' to delete to the end of the line.
\item[Line mode] This is the mode when you press a : in command mode, this is where you can type some powerful (and sed like) commands to alter the document. \end{description}

Rather than bore you with yet another description I will give you a series of exercises to work through showing each command. In the examples <esc> means to press the escape key. This will return you to command mode or cancel an action in other modes.

%------------------------------------------------------------------------------
\subsubsection{Inserting text}

There are at least three ways to insert text into a document in vi,
the following exercises will take you through the basic commands.

\begin{description}
\item [Exercise 1 - insert] Create a text document, just to get you
  used to switching in and out of the insert and command mode.
\begin{alltt}
\$ vi test.txt \(\hookleftarrow\)
ithis is the Linux course<return>
We want a few lines of txt to work with. <esc>
\end{alltt}
The i inserts text before the cursor. 

\item [Exercise 2 - open] We want to add some extra text to the
  document, we want to enter it on the line after the current line, we
  use the open command by pressing \textsf{o}.
\begin{alltt}
oI am adding an line after the current line.<esc>
\end{alltt}
\item[Exercise 3 - append] Now I want ot continue adding another
  sentence on the current line. If I press 'i' I will insert before
  the full stop, in this case I want to append it after the full stop.
\begin{alltt}
a I want to add another sentence.<esc>
\end{alltt}
You line should now look like:
\begin{alltt}
I am adding an line after the current line. I want to 
add another sentence.
\end{alltt}
\end{description}

%------------------------------------------------------------------------------
\subsubsection{Movement keys \& multiplication}
  There are a huge number of ways to move around in vi, the arrow keys
  will not always work . You should be aware of the single character
  work arounds for these in case your terminal is not set up properly
  on the box you are 'telnet'ing or 'ssh'ing from or to.

\begin{description}
\item[h] Left one character *
\item[j] Down one line *
\item[k] Up one line *
\item[l] Left one character *
\item[w] Forward one word
\item[b] Back one word
\item[e] End of current word
\item[G] End of file *
\item[nG] Goto a particular line *
\item[\{] Back one paragraph
\item[\}] Forward one paragraph
\item[\$] End of current line
\item[\textasciicircum] First non blank character in line
\item[0] Beginning of line (also \verb+|+)
\end{description}

Ones marked with an asterisk are required by POMS, Personally I find
word movement is my main tool here. I also use the control keys to
scroll screens a far bit. These are listed on the printed cheat sheet.

ALL these movement commands can be prefixed by a number to multiply the
effect of the movement. To move up 99 lines enter 99k.

Note that some vi editor have a status on the bottom line, sometime it will show that you have entered a multiplier, sometimes it is quiet but the results are \_unexpected\_.

\begin{description}
\item[Exercise 4 - back] In the previous exercise I have forgotten a
  word after the an I wanted the word 'extra'. I have to go back that
  position in the line.
  
  \texttt{12b} will get me back to the beginning of the word I want to
  insert before, this is an example of a count followed by a command.
  
  Warning on the counts it can repeat most commands whether it makes
  sense or not at the time. For example enter the following:
  \begin{alltt}
4iextra <esc>    
  \end{alltt}
  
  What happened? Why?
  
  This is handy with asterisks \texttt{70i*<esc>}, try it.
  
  \texttt{12b} moves the cursor back 12 words. A word is a sequence of
  characters separated by a space character like a <space> or a <tab>
  Also the punctuation characters or '.', '?', ';' and so on.
  
\item[Exercise 5 - general movement] Edit a large text file on your
  system. You should be able to do the following with two keystrokes.
  \begin{itemize}
  \item Jump to line 6
  \item Move 8 character to the right.
  \item Go to the end of the line
  \item Go to the beginning of the line.
  \item Jump to the top of the paragraph in the document (a paragraph is delimited by blank lines.)
  \end{itemize}
  You should be able to do this with one keystroke
  \begin{itemize}
  \item Move to the left margin 
    To the end of the line 
  \item Move to the end
    of the file.
  \end{itemize}
\end{description}

%------------------------------------------------------------------------------
\subsubsection{The undo command}

The real vi command undo is very very limited. It does not allow for
a lot of recovery. There are two undo commands 'U' and 'u'.

The lower case u will undo the last action that you have done. This
includes itself so it will cycle through doing and undoing.

The upper case U will undo the any change to the current line and
restore it back to its original state.

Extended vi editors such as vim will allow multiple lower case u undo
commands but do not rely on it on an unknown box. To get out of a
problem you simply have to quit without with ':q!'.

No exercise here, I figure you will find this out without any help.
Try both commands. Check the difference.

%------------------------------------------------------------------------------
\subsubsection{Deleting changing and copying text}
\begin{description}
\item[d] Delete *
\item[c] Change *
\item[x] Delete one character
\item[y] Yank (copy text)
\end{description}

Ones marked with an asterisk are required by POMS, Personally I use
single character deletion all the time. I use line deletion all the
time.

There delete command and yank command can be used with a movement to
delete all text within this movement. For example d\$ will delete to
the end of the current line, y\$ will yank it into a buffer. Delete
will also store the deletion in a buffer to get it back quickly just
use paste describe later.

To delete or yank a line simply repeat the d or y. To delete a single
line use dd, to delete the current line and the next two use 3dd. To
yank the next 10 lines use 10yy.

Exercise 6

Please your cursor in the middle of a line. Delete from the current
position to the beginning of the line with two keystrokes.

Delete from the current position to the end of the line.

Note that there is a shorthand for d\$ (delete, move to end of line)
by using a capital D. Move to the centre of a line of text and try it.


%=============================================================================
%=============================================================================
\setcounter{chapter}{103} 
\chapter{Devices, Linux Filesystems \& FHS}
\label{ch:104.ex}

{\Large Old number: (2.4)}\\[2mm]
{\Large Weight: [21]}

\section*{Create partitions and filesystems [3]}
\section*{Maintain the integrity of filesystems [5]}
\section*{Control mounting and unmounting filesystems [3]}
\section*{Managing disk quota [1]}
\section*{Use file permissions to control access to files [3]}
\section*{Manage file ownership [2]}
\section*{Create and change hard and symbolic links [2]}
\section*{Find system files and place files in the correct location [2]}

\newpage
%=============================================================================
\section{Create partitions and filesystems [3]}
\label{sec:104.1.ex}

%------------------------------------------------------------------------------
\subsection{Using \texttt{fdisk}}
\label{sec:ex.104.1.1}

Care must be taken using \texttt{fdisk} as any changes to your disk's
partition table will make existing data on the disk unaccessible.
There is debate about what the ``\texttt{f}'' in \texttt{fdisk} stands for.

%------------------------------------------------------------------------------
\subsubsection{Using \texttt{fdisk} non-destructively on a hard disk}
\label{sec:ex.104.1.1.1}

\begin{itemize}
\item View the partition table for the hard disk:
\begin{alltt}
\# fdisk -l /dev/hda \(\hookleftarrow\)

Disk /dev/hda: 255 heads, 63 sectors, 3648 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot Start   End    Blocks   Id  System
/dev/hda1   *      1   768   6168928+   c  Win95 FAT32 (LBA)
/dev/hda2        769  3648  23133600    5  Extended
/dev/hda5        769   780     96358+  83  Linux
\end{alltt}
\item Print the size of a partition in blocks (30G disk):
\begin{alltt}
\# fdisk -s /dev/hda \(\hookleftarrow\)
29302560
\# fdisk -s /dev/hda5 \(\hookleftarrow\)
96358
\end{alltt}
\end{itemize}

%------------------------------------------------------------------------------
\subsubsection{Using \texttt{fdisk} on a diskette}
\label{sec:ex.104.1.1.2}

Warning: it makes no sense to use \texttt{fdisk} on a
  floppy---this is just an exercise.

\begin{itemize}
\item Format the floppy disk:
\begin{alltt}
\# fdformat /dev/fd0 \(\hookleftarrow\)     
\end{alltt}
\item Start fdisk using the floppy diskette:
\begin{alltt}
\# fdisk /dev/hda \(\hookleftarrow\)  
\end{alltt}
\item Look at the menu:
\begin{alltt}    
Command (m for help): m \(\hookleftarrow\)
\end{alltt}
\item Print the partition table:
\begin{alltt}    
Command (m for help): p \(\hookleftarrow\)

Disk /dev/fd0: 2 heads, 18 sectors, 80 cylinders
Units = cylinders of 36 * 512 bytes

    Device Boot    Start       End    Blocks   Id  System
\end{alltt}
\item Use \textsf{n} for new and construct this partition table:
\begin{alltt}  
    Device Boot    Start       End    Blocks   Id  System
/dev/fd0p1 *           1        20       351    1  FAT12
/dev/fd0p2            21        25        90   83  Linux
/dev/fd0p3            26        80       990    5  Extended
/dev/fd0p5            26        30        81   83  Linux
/dev/fd0p6            31        70       711   83  Linux
/dev/fd0p7            71        80       171   83  Linux   
\end{alltt}
\item List the partition types:
  \begin{alltt}
Command (m for help): l \(\hookleftarrow\)    
  \end{alltt}
\item Change the first partition to type 1:
  \begin{alltt}
Command (m for help): t \(\hookleftarrow\)    
  \end{alltt}
\item Toggle the bootable flag on the first partition:
  \begin{alltt}
Command (m for help): a \(\hookleftarrow\)    
  \end{alltt}
\end{itemize}

%------------------------------------------------------------------------------
\subsubsection{Using \texttt{cfdisk}}
\label{sec:ex.104.1.1.3}

\texttt{cfdisk} is reputably more user friendly than \texttt{fdisk}.
There are some partition adjustments that may require \texttt{cfdisk}.

Have a look at your floppy diskette partitions:
\begin{alltt}
\# cfdisk /dev/fd0 \(\hookleftarrow\)  
\end{alltt}

%------------------------------------------------------------------------------
\subsubsection{Using \texttt{sfdisk}}
\label{sec:ex.104.1.1.3}

\texttt{sfdisk} is interactive partition editor.

Have a look at your floppy diskette partitions:
\begin{alltt}
\# sfdisk /dev/fd0 \(\hookleftarrow\)  
\end{alltt}
You may wish to \textsf{Cntl-C} out of this program if you wish not to
edit the partition table.

%------------------------------------------------------------------------------
\subsubsection{Using \texttt{GNU parted}}
\label{sec:ex.104.1.1.3}

\texttt{parted} is a partition editor that can resize partitions.

\begin{itemize}
\item Have a look at your floppy diskette partitions:
\begin{alltt}
\# parted /dev/fd0 \(\hookleftarrow\)  
\end{alltt}
\item Check the menu:
\begin{alltt}
(parted) p \(\hookleftarrow\)   
\end{alltt}
\item Experiment on you partitioned floppy.
\end{itemize}


\newpage
%=============================================================================
\section{Maintain the integrity of filesystems [5]}
\label{sec:104.2.ex}

\newpage
%=============================================================================
\section{Control mounting and unmounting filesystems [3]}
\label{sec:104.3.ex}

\newpage
%=============================================================================
\section{Managing disk quota [1]}
\label{sec:104.4.ex}

\newpage
%=============================================================================
\section{Use file permissions to control access to files [3]}
\label{sec:104.5.ex}

\newpage
%=============================================================================
\section{Manage file ownership [2]}
\label{sec:104.6.ex}

\newpage
%=============================================================================
\section{Create and change hard and symbolic links [2]}
\label{sec:104.7.ex}

\newpage
%=============================================================================
\section{Find system files and place files in the correct location [2]}
\label{sec:104.8.ex}


%=============================================================================
%=============================================================================
%=============================================================================
\part{Questions}

%=============================================================================
%=============================================================================
% \setcounter{chapter}{0}
% \chapter{General Linux Part 1 [89]} 

%=============================================================================
\setcounter{section}{102} 
\section{(1.3) GNU \& Unix Commands [30]} 

%\newpage
%------------------------------------------------------------------------------
\subsection{Work on the command line [4]}
\label{sec:1.103.1.q}

%\newpage
%------------------------------------------------------------------------------
\subsection{Process text streams using filters [7]}
\label{sec:1.103.2.q}

%\newpage
%------------------------------------------------------------------------------
\subsection{Perform basic file management [2]}
\label{sec:1.103.3.q}

%\newpage
%------------------------------------------------------------------------------
\subsection{Use streams, pipes, and redirects [3]}
\label{sec:1.103.4.q}

%\newpage
%------------------------------------------------------------------------------
\subsection{Create, monitor, and kill processes [7]}
\label{sec:1.103.5.q}

%\newpage
%------------------------------------------------------------------------------
\subsection{Modify process execution priorities [2]}
\label{sec:1.103.6.q}

%\newpage
%------------------------------------------------------------------------------
\subsection{Search text files using regular expressions [3]}
\label{sec:1.103.7.q}
 
\newpage
%------------------------------------------------------------------------------
\subsection{Perform basic file editing using \textsf{vi} [2]}
\label{sec:1.103.8.q}

\begin{enumerate}
\item How do you quit \textsf{vi} without saving?  \verb+__________________+

\item In \textsf{vi} command mode what does the \texttt{p} key do? 
 \verb+___________+


\item The \textsf{vi} editor has three modes. Name them:
\\[3mm] \verb+______________ ________________ ____________________+
\item In \textsf{vi} insert mode what does the following key sequence
  do? \\ \texttt{<esc>:wq\(\hookleftarrow\)}
  \verb+_________________________________________+

\item How do you search forward for the next occurrence of the word ``from'' in \textsf{vi}. \verb+________+

\item What command will delete the next 23 lines of text in
  \textsf{vi}. \verb+________+

\item Which command inserts text into \textsf{vi} at the current
  cursor location?
  \begin{enumerate}
  \item \texttt{a}
  \item \texttt{f}
  \item \texttt{T}
  \item \texttt{i}
  \end{enumerate}

\item Which way does cursor move when you press each of these keys in \textsf{vi} command mode?
  \begin{description}
  \item[k] \verb+_____________+
  \item[h] \verb+_____________+
  \item[l] \verb+_____________+
  \item[j] \verb+_____________+
  \end{description}
  
\item In \textsf{vi} command mode what does the \texttt{u} key do?
  \\[3mm]\verb+____________________________________________________+

\item In the \textsf{vi} editor what does the term ``yank'' mean.?
\\[3mm]\verb+____________________________________________________+

\newpage
\item What do you type to repeat the last command? \verb+________+
  
\item In \textsf{vi} command mode to move a line from its current
  position to three lines down the page you would enter:
  \begin{enumerate}
  \item \texttt{3dd3lp}
  \item \texttt{ddk3p}
  \item \texttt{1dd3p}
  \item \texttt{dd3kp}
  \end{enumerate}

\item This command moves three lines of text into a \textsf{vi} buffer
  named \texttt{a}:
  \begin{enumerate}
  \item \texttt{"a3dd}%*
  \item \texttt{a3dd}
  \item \texttt{"add3}
  \item \texttt{A5dd}
  \end{enumerate}

\item The G command does what? \verb+_______________________________+
\end{enumerate}


%=============================================================================
%=============================================================================
%=============================================================================
\part{Meta}

%=============================================================================
%=============================================================================
% \setcounter{chapter}{}
\chapter{Making Slides Using \LaTeX\ } 

%=============================================================================
\setcounter{section}{0} 
\section{Making a} 

\begin{itemize}
\item Install the acutex package for emacs
\item Open a new document:
\begin{alltt}
\$ emacs my.slides.tex \(\hookleftarrow\)    
\end{alltt}
\item In emacs create a document environment: \textsf{C-C C-E} Enter for the default (document) in the mini buffer.
\item For document style enter: \texttt{seminar}
\item For options enter: \texttt{a4}
\end{itemize}

\framebox{
\begin{minipage}[t]{30mm}
  \begin{itemize}
  \item aaaaaaa
  \item dddddddd
  \item wwww
  \item cc
  \end{itemize}
\end{minipage}}
%
\framebox{
\begin{minipage}[t]{50mm}
  \begin{itemize}
  \item aaaaaaa
  \item dddddddd
  \item wwww
  \item cc
  \end{itemize}
\end{minipage}}


  \begin{rotate}{45}
    blah
  \end{rotate}


\rotr{90}{blah de blah de blah}


%=============================================================================
\end{document}%===============================================================
%=============================================================================
\begin{alltt}
\$  \(\hookleftarrow\)    
\end{alltt}
%==============================================================================
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%------------------------------------------------------------------------------
%..............................................................................

%------------------------------------------------------------------------------
\subsection{ Modify process execution priorities [2]}


\item \verb+________+

\item 
  \begin{enumerate}
  \item \texttt{}
  \item \texttt{}
  \item \texttt{}
  \item \texttt{}
  \end{enumerate}
\end{enumerate}

