\documentclass[a4paper,11pt]{article}
\usepackage{url,mdwlist,booktabs,acro,nick,varioref,alltt,cols,fancyhdr,rcs}
\usepackage[margin=20mm]{geometry}
\RCS $Revision: 1.0 $

\pagestyle{fancyplain}
\fancypagestyle{plain}{%
  \fancyhead{}%
  %\setlength{\headrulewidth}{0pt}%
  \renewcommand*{\headrulewidth}{0pt}%
  \fancyfoot[LE,RO]{\tiny ver. \RCSRevision}%
  %\fancyfoot[LO,RE]{\tiny Nick Urbanik \url{<nicku(at)nicku.org>}}%
  \fancyfoot[LO,RE]{}
  \fancyfoot[C]{}%
}

\newcommand*{\subject}{Some Supplementary Notes for OSSI}
\newcommand*{\headerfont}{\rmfamily\footnotesize\bfseries}

\fancyfoot[C]{}%
\fancyfoot[LE,RO]{\tiny ver. \RCSRevision}%
%\fancyfoot[LO,RE]{\tiny Nick Urbanik \url{<nicku(at)nicku.org>}}%
\fancyfoot[LO,RE]{}
\fancyhead[LO,RE]{\headerfont\subject}
\fancyhead[LE,RO]{\headerfont\thepage}
%\fancyhead[C]{\headerfont\subject}

\newlength{\prototypewidth}
\newlength{\returnvalwidth}
\setlength{\prototypewidth}{0.4\linewidth}
\setlength{\returnvalwidth}{0.6\linewidth}
\newcommand*{\interskip}{\bigskip}
\newlength{\shrinkprotoskip}
\setlength{\shrinkprotoskip}{-4ex}
\newlength{\shrinkretskip}
\setlength{\shrinkretskip}{-2ex}
\newlength{\shrinkparskip}
\setlength{\shrinkparskip}{-1.5ex}

\begin{document}

%% \section{Function Prototypes for some POSIX System and Library Calls}
%% \label{apx:system-calls}

%% \vspace*{-1ex}
%% {\small%
%% \textbf{\textsf{fork()}}:\\
%% \begin{minipage}[t]{\prototypewidth}
%% \vspace*{\shrinkprotoskip}
%% %[
%% #include <unistd.h>
%% pid_t fork( void );
%% %]
%% \end{minipage}%
%% \begin{minipage}[t]{\returnvalwidth}
%% Return value from @fork()@
%% \vspace*{\shrinkretskip}
%%   \begin{itemize*}
%%   \item 0 in child process
%%   \item process \ID (\PID) of child in parent process
%%   \item $-1$ if error
%%   \end{itemize*}
%% \end{minipage}

%% %\interskip

%% \vspace*{2ex}

%% \textbf{\textsf{execl()}}:\\
%% \begin{minipage}[t]{1.5\prototypewidth}
%% \vspace*{\shrinkprotoskip}
%% %[
%% #include <unistd.h>
%% int execl( const char *path, const char *arg, ... );
%% %]
%% \end{minipage}

%% \smallskip

%% \begin{minipage}[t]{0.7\returnvalwidth}
%% Return value from @execl()@:
%% \vspace*{\shrinkretskip}
%% \begin{itemize*}
%% \item $-1$ if error
%% \end{itemize*}
%% \end{minipage}

%% \smallskip

%% Parameters:
%% \vspace*{\shrinkparskip}
%% \begin{itemize*}
%% \item first gives full path of the program file you want to execute
%% \item second gives name of the new process
%% \end{itemize*}
%% \vspace*{-1ex}
%% Remaining parameters are command line arguments you pass to the
%% program.  The last parameter must be a @NULL@  pointer, to end
%% the parameter list.

%% \interskip

%% %\vspace*{1ex}

%% \textbf{\textsf{wait()}}:\\
%% \begin{minipage}[t]{\prototypewidth}
%% \vspace*{\shrinkprotoskip}
%% %[
%% #include <sys/wait.h>
%% pid_t wait( int *status );
%% %]
%% \end{minipage}%
%% \begin{minipage}[t]{\returnvalwidth}
%% Return value from @wait()@:
%% \vspace*{\shrinkretskip}
%% \begin{itemize*}
%% \item process \ID of child if successful,
%% \item $-1$ if error
%% \end{itemize*}
%% \end{minipage}

%% \interskip

%% \vspace*{-1ex}

%% \textbf{\textsf{pipe()}}:\\
%% \begin{minipage}[t]{\prototypewidth}
%% \vspace*{\shrinkprotoskip}
%% %[
%% #include <unistd.h>
%% int pipe( int filedes[2] );
%% %]
%% \end{minipage}%
%% \begin{minipage}[t]{\returnvalwidth}
%% Return value from @pipe()@:
%% \vspace*{\shrinkretskip}
%% \begin{itemize*}
%% \item 0 if successful
%% \item $-1$ if error
%% \end{itemize*}
%% \end{minipage}

%% \smallskip

%% Parameter to @pipe()@ is an array of two file descriptors.
%% \vspace*{\shrinkparskip}
%% \begin{itemize*}
%% \item the reader reads from the first one, @filedes[0]@
%% \item the writer writes to the second one, @filedes[1]@
%% \end{itemize*}

%% \vspace*{1ex}

%% \textbf{\textsf{read()}}:\\
%% \begin{minipage}[t]{\prototypewidth}
%% \vspace*{\shrinkprotoskip}
%% %[
%% #include <unistd.h>
%% ssize_t read(int fd, void *buf, size_t count);
%% %]
%% \end{minipage}

%% \smallskip

%% %\begin{minipage}[t]{\returnvalwidth}
%% Return value from @read()@:
%% \vspace*{0.9\shrinkretskip}
%% \begin{itemize*}
%% \item On success, number of bytes read; zero indicates end of file
%% \item $-1$ if error
%% \end{itemize*}
%% %\end{minipage}

%% \interskip

%% \vspace*{-2ex}

%% \textbf{\textsf{write()}}:\\
%% \begin{minipage}[t]{\prototypewidth}
%% \vspace*{\shrinkprotoskip}
%% %[
%% #include <unistd.h>
%% ssize_t write(int fd, const void *buf, size_t count);
%% %]
%% \end{minipage}

%% \smallskip

%% %\begin{minipage}[t]{\returnvalwidth}
%% Return value from @write()@:
%% \vspace*{0.9\shrinkretskip}
%% \begin{itemize*}
%% \item On success, number of bytes written; zero indicates nothing was written.
%% \item $-1$ if error
%% \end{itemize*}
%% %\end{minipage}

%% %\smallskip

%% \enlargethispage{\baselineskip}

%% Parameters for @read()@ and @write()@:
%% \vspace*{\shrinkparskip}
%% \begin{itemize*}
%% \item first parameter is a file descriptor
%% \item second is the character array to @read()@ into or the character
%%   array (string) to @write()@ from
%% \item third parameter is the maximum number of bytes to be read or written
%% \end{itemize*}
%% }

%% \textbf{\textsf{The C Preincrement Operator ++}}

%% The following C program statements:
%% %[
%% int a = 0;
%% printf( "%d\n", ++a );
%% printf( "%d\n", a );
%% %]
%% produce the following output:

%% \vspace*{-2ex}

%% \begin{verbatim}
%% 1
%% 1
%% \end{verbatim}

%% \section{Extract from POSIX definition of the \texttt{expr}
%%   command}
%% \label{apx:expr-command}
%% %http://www.opengroup.org/onlinepubs/007904975/utilities/expr.html

%% The \texttt{expr} utility shall evaluate the expression and write the
%% result, followed by a \texttt{\textless{}newline\textgreater{}}, to standard
%% output.

%% \noindent%
%% \begin{tabularx}{\linewidth}[t]{|>{\ttfamily}l|X|}
%%   \hline%
%%   expr1 + expr2 &
%%   Addition of decimal integer-valued arguments.\\ \hline%
%%   expr1 - expr2 &
%%   Subtraction of decimal integer-valued arguments.\\ \hline%
%%   expr1 * expr2 &
%%   Multiplication of decimal integer-valued arguments.\\ \hline%
%%   expr1 / expr2 &
%%   Integer division of decimal integer-valued arguments, producing an integer result. \\ \hline%
%%   expr1 \% expr2 &
%%   Remainder of integer division of decimal integer-valued arguments.\\
%%   \hline%
%%   ( expr ) & Grouping symbols. Any expression can be placed within
%%   parentheses. 
%%   % Parentheses can be nested to a depth of
%%   % \texttt{\{EXPR\_NEST\_MAX\}}.
%%   \\ \hline%
%% \end{tabularx}

%% \vspace{2ex}

%% The \texttt{expr} utility has a rather difficult syntax:
%%  \begin{itemize*}
%%  \item Many of the operators are also shell control operators or
%%    reserved words, so they have to be escaped on the command line.
  
%%  \item Each part of the expression is composed of separate arguments,
%%    so liberal usage of \texttt{\textless{}blank\textgreater{}}s is
%%    required. For example: \newlength{\colwidth}
%%    \settowidth{\colwidth}{\texttt{expr 1 + \bs( 2 \bs* 3 \bs)}}

%%   \begin{center}
%%     \begin{tabularx}{2.3\colwidth}[t]{|>{\ttfamily}C|>{\ttfamily}C|}
%%       \hline
%%       \textnormal{Invalid} & \textnormal{Valid} \\
%%       \hline
%%       expr 1+2 &
%%       expr 1 + 2 \\
%%       \hline
%%       expr "1 + 2" &
%%       expr 1 + 2 \\
%%       \hline
%%       expr 1 + (2 * 3) &
%%       expr 1 + \bs( 2 \bs* 3 \bs) \\
%%       \hline
%%     \end{tabularx}
%%   \end{center}
%%  \end{itemize*}

%% \section{\texttt{useradd}: an extract from the Linux Standard Base
%%   Specification 1.1}
%% \label{apx:useradd}

%% \subsection*{Name}

%% \texttt{\textbf{useradd}} --- create a new user or update default new user information

%% \subsection*{Synopsis}

%%  \begin{alltt}
%%  \textbf{useradd} [\textbf{-c} comment] [\textbf{-d} home_dir]
%%          [\textbf{-e} expire_date] [\textbf{-f} inactive_time]
%%          [\textbf{-g} initial_group] [\textbf{-G} group[,...]]
%%          [\textbf{-m} [\textbf{-k} skeleton_dir]] [\textbf{-p} passwd] [\textbf{-r}]
%%          [\textbf{-s} shell] [\textbf{-u} uid [ \textbf{-o}]] login

%%  \textbf{useradd -D} [\textbf{-g} default_group] [\textbf{-b} default_home]
%%             [\textbf{-f} default_inactive] [\textbf{-e} default_expire_date]
%%             [\textbf{-s} default_shell]
%% \end{alltt}
          

%% \subsection*{Description}

%% When invoked without the \texttt{\textbf{-D}} option, \texttt{useradd}
%% creates a new user account using the values specified on the command
%% line and the default values from the system. The new user account will
%% be entered into the system files as needed, the home directory will be
%% created, and initial files copied, depending on the command line
%% options.

%% When invoked with the \texttt{\textbf{-D}} option, \texttt{useradd}
%% will either display the current default values, or update the default
%% values from the command line. If no options are specified,
%% \textbf{useradd} displays the current default values.

%% \subsection*{Standard Options}
%%   \begin{description}
%%     \makeatletter
%%     \itemsep    2.5\p@ \@plus\p@    \@minus\p@
%%     \makeatother
%%   \item[\texttt{\textbf{-c} comment}]
  
%%     specifies the new user's password file comment field value.

%%   \item[\texttt{\textbf{-d} home\_dir}]
  
%%     creates the new user using \texttt{home\_dir} as the value for the
%%     user's login directory. The default is to append the login name to
%%     \texttt{default\_home} and use that as the login directory name.

%%   \item[\texttt{\textbf{-e} expire\_date}]
  
%%     specifies the date on which the user account will be disabled. The
%%     date is specified in the format YYYY-MM-DD.

%%   \item[\texttt{\textbf{-f} inactive\_days}]
    
%%     specifies the number of days after a password expires until the
%%     account is permanently disabled. A value of 0 disables the account
%%     as soon as the password has expired, and a value of $-1$ disables
%%     the feature. The default value is $-1$.

%%   \item[\texttt{\textbf{-g} initial\_group}]
    
%%     specifies the group name or number of the user's initial login
%%     group. The group name must exist. A group number must refer to an
%%     already existing group.  If \texttt{\textbf{-g}} is not specified,
%%     the implementation will follow the normal user default for that
%%     system.  This may create a new group or choose a default group
%%     that normal users are placed in.  Applications which require
%%     control of the groups into which a user is placed should specify
%%     \texttt{\textbf{-g}}.

%%   \item[\texttt{\textbf{-G} group,{[...]}}]
  
%%     specifies a list of supplementary groups which the user is also a
%%     member of. Each group is separated from the next by a comma, with
%%     no intervening whitespace. The groups are subject to the same
%%     restrictions as the group given with the \texttt{\textbf{-g}}
%%     option. The default is for the user to belong only to the initial
%%     group.

%%   \item[\texttt{\textbf{-m} {[\textbf{-k} skeleton\_dir]}}]
  
%%     specifies the user's home directory will be created if it does not
%%     exist. The files contained in \texttt{skeleton\_dir} will be
%%     copied to the home directory if the \texttt{\textbf{-k}} option is
%%     used, otherwise the files contained in \texttt{/etc/skel} will be
%%     used instead. Any directories contained in \texttt{skeleton\_dir}
%%     or \texttt{/etc/skel} will be created in the user's home directory
%%     as well. The \texttt{\textbf{-k}} option is only valid in
%%     conjunction with the \texttt{\textbf{-m}} option. The default is
%%     to not create the directory and to not copy any files.

%%   \item[\texttt{\textbf{-p} passwd}]
  
%%     is the encrypted password, as returned by \texttt{crypt(3)}. The
%%     default is to disable the account.

%%   \item[\texttt{\textbf{-r}}]
  
%%     creates a system account, that is, a user with a UID in the range
%%     reserved for system account users. If there is not a UID free in
%%     the reserved range the command will fail.

%%   \item[\texttt{\textbf{-s} shell}]
  
%%     specifies the name of the user's login shell. The default is to
%%     leave this field blank, which causes the system to select the
%%     default login shell.

%%   \item[\texttt{\textbf{-u} uid [\textbf{-o}]}]
  
%%     specifies the numerical value of the user's ID. This value must be
%%     unique, unless the \texttt{\textbf{-o}} option is used. The value
%%     must be non-negative. The default is the smallest ID value greater
%%     than 499 which is not yet used.
%%   \end{description}
  
%% \subsection*{Change Default Options}

%%   \begin{description}
%%     \makeatletter
%%     \itemsep    2.5\p@ \@plus\p@    \@minus\p@
%%     \makeatother
%%   \item[\texttt{\textbf{-b} default\_home}]
  
%%     specifies the initial path prefix for a new user's home directory.
%%     The user's name will be affixed to the end of
%%     \texttt{default\_home} to create the new directory name if the
%%     \texttt{\textbf{-d}} option is not used when creating a new
%%     account.

%%   \item[\texttt{\textbf{-e} default\_expire\_date}]
  
%%     specifies the date on which the user account is disabled.

%%   \item[\texttt{\textbf{-f} default\_inactive}]
  
%%     specifies the number of days after a password has expired before
%%     the account will be disabled.

%%   \item[\texttt{\textbf{-g} default\_group}]
  
%%     specifies the group name or ID for a new user's initial group. The
%%     named group must exist, and a numerical group ID must have an
%%     existing entry.

%%   \item[\texttt{\textbf{-s} default\_shell}]
  
%%     specifies the name of the new user's login shell. The named
%%     program will be used for all future new user accounts.

%%   \item[\texttt{\textbf{-c} comment}]
  
%%     specifies the new user's password file comment field value.
%%   \end{description}
  
%% \subsection*{Application Usage}

%% The \texttt{\textbf{-D}} option will typically be used by
%% system administration packages.  Most applications should not change
%% defaults which will affect other applications and users.

%% \subsection*{Files}
%% \begin{indentLeft}
%%        \texttt{\textbf{/etc/passwd}} --- user account information\\
%%        \texttt{\textbf{/etc/shadow}} --- secure user account information\\
%%        \texttt{\textbf{/etc/group}} --- group information\\
%%        \texttt{\textbf{/etc/skel}} --- directory containing default files
%% \end{indentLeft}
     

% groupadd -- create a new group

% \section{\texttt{groupadd}: an extract from the Linux Standard Base
%   Specification 1.1}
% \label{apx:groupadd}

% \begin{alltt}
% {\Large\textbf{groupadd}}

% \textbf{Name}

% groupadd -- create a new group

% \textbf{Synopsis}

%  groupadd [-g gid [-o]] group

% \textbf{Options}

% -g gid [-o]
%   specifies the numerical value of the group's ID. This value must be
%   unique, unless the -o option is used. The value must be non-negative.
% \end{alltt}

\section{\texttt{test}: extract from POSIX definition of the \texttt{test} command}
\label{apx:test-command}

\textbf{NAME}

    test - evaluate expression

\vspace{1ex}

\textbf{SYNOPSIS}
\begin{alltt}
    test \textbf{[expression]}

    [ \textbf{[expression]} ]
\end{alltt}

\vspace{1ex}

\textbf{DESCRIPTION}

The test utility shall evaluate the expression and indicate the result
of the evaluation by its exit status.  An exit status of zero indicates
that the expression evaluated as true and an exit status of 1
indicates that the expression evaluated as false.

In the second form of the utility, which uses ``\texttt{[]}'' rather than test,
the application shall ensure that the square brackets are separate
arguments.

\vspace{1ex}

\textbf{OPERANDS}

The application shall ensure that all operators and elements of
primaries are presented as separate arguments to the test utility.

The following primaries can be used to construct expression:
\begin{description}
%% \makeatletter
%%  \itemsep    2.5\p@ \@plus\p@    \@minus\p@
%% \makeatother
 \itemsep    2.5pt plus 1pt minus 1pt
    \item[\texttt{-b  file}]
       True if \texttt{file} exists and is a block special file. 
    \item[\texttt{-c  file}]
       True if \texttt{file} exists and is a character special file. 
    \item[\texttt{-d  file}] 
       True if \texttt{file} exists and is a directory. 
    \item[\texttt{-e  file}] 
       True if \texttt{file} exists. 
    \item[\texttt{-f  file}] 
       True if \texttt{file} exists and is a regular file. 
    \item[\texttt{-g  file}] 
       True if \texttt{file} exists and its set-group-ID flag is set. 
    \item[\texttt{-h  file}] 
       True if \texttt{file} exists and is a symbolic link. 
    \item[\texttt{-L  file}] 
       True if \texttt{file} exists and is a symbolic link. 
    \item[\texttt{-n  string}] 
       True if the length of \texttt{string} is non-zero. 
    \item[\texttt{-p  file}] 
       True if \texttt{file} is a \FIFO. 
    \item[\texttt{-r  file}] 
       True if \texttt{file} exists and is readable. True shall indicate that permission to read from \texttt{file} will be granted, as defined in File Read, Write, and Creation.
    \item[\texttt{-S  file}] 
       True if \texttt{file} exists and is a socket. 
    \item[\texttt{-s  file}] 
       True if \texttt{file} exists and has a size greater than zero. 
    \item[\texttt{-t  file\_descriptor}] 
      
      True if the file whose file descriptor number is
      \texttt{file\_descriptor} is open and is associated with a
      terminal.
    \item[\texttt{-u  file}] 
       True if \texttt{file} exists and its set-user-ID flag is set. 
    \item[\texttt{-w  file}] 
       True if \texttt{file} exists and is writable. True shall indicate that permission to write from \texttt{file} will be granted, as defined in File Read, Write, and Creation.
    \item[\texttt{-x  file}] 
       True if \texttt{file} exists and is executable. True shall indicate that permission to execute \texttt{file} will be granted, as defined in File Read, Write, and Creation.
       If \texttt{file} is a directory, true shall indicate that permission to search \texttt{file} will be granted. 
    \item[\texttt{-z  string}] 
       True if the length of string \texttt{string} is zero. 
    \item[\texttt{string}] 
       True if the string \texttt{string} is not the null string. 
    \item[\texttt{s1 =  s2}] 
       True if the strings \texttt{s1} and \texttt{s2} are identical. 
    \item[\texttt{s1 !=  s2}] 
       True if the strings \texttt{s1} and \texttt{s2} are not identical. 
     \item[\texttt{n1 -eq n2}] True if the integers \texttt{n1} and \texttt{n2} are
       algebraically equal.
    \item[\texttt{n1 -ne  n2}] 
       True if the integers \texttt{n1} and \texttt{n2} are not algebraically equal. 
    \item[\texttt{n1 -gt  n2}] 
       True if the integer \texttt{n1} is algebraically greater than the integer \texttt{n2}. 
    \item[\texttt{n1 -ge  n2}] 
       True if the integer \texttt{n1} is algebraically greater than or equal to the integer \texttt{n2}. 
    \item[\texttt{n1 -lt  n2}] 
       True if the integer \texttt{n1} is algebraically less than the integer \texttt{n2}. 
    \item[\texttt{n1 -le  n2}] 
       True if the integer \texttt{n1} is algebraically less than or equal to the integer \texttt{n2}. 
     \item[\texttt{expression1 -a expression2}] True if both
       \texttt{expression1} and \texttt{expression2} are true. The
       \texttt{-a} binary primary is left associative. It has a higher
       precedence than \texttt{-o}.
     \item[\texttt{expression1 -o expression2}] True if either
       \texttt{expression1} or \texttt{expression2} is true. The
       \texttt{-o} binary primary is left associative.
  \end{description}

%% \section{\texttt{sh}: Positional Parameters and some Special Parameters for the Bourne Shell}
%% \label{apx:shell-parameters}


%% \subsection*{Positional Shell Parameters}
%% \label{sec:positional-parameters}

%% A \emph{positional parameter} is a parameter denoted by one or more
%% digits, other than the single digit 0, e.g., \texttt{\$1},
%% \texttt{\$2}. Positional parameters are assigned from the shell's
%% arguments when it is invoked, and may be reassigned using the
%% \texttt{set} builtin command.  Positional parameters may not be
%% assigned to with assignment statements.  The positional parameters are
%% temporarily replaced when a shell function is executed

%% When a positional parameter consisting of more than a single digit
%% is expanded, it must be enclosed in braces.

%% \subsection*{Special Shell Parameters}
%% \label{sec:special-parameters}

%% %@-
%% \begin{tabularx}{\linewidth}{@{}>{\ttfamily}lY@{}}
%% %@-
%%   \$* & Expands to the positional parameters, starting from one.  When
%%   the expansion occurs within double quotes, it expands to a single
%%   word with the value of each parameter separated by the first
%%   character of the \texttt{IFS} special variable.  That is,
%%   \texttt{"\$*"} is equivalent to \texttt{"\$1c\$2c..."}, where
%%   \texttt{c} is the first character of the value of the \texttt{IFS}
%%   variable.  If \texttt{IFS} is unset, the parameters are separated by
%%   spaces.  If \texttt{IFS} is null, the parameters are joined without
%%   intervening separators.\\
%% %@-
%%   \$@ & Expands to the positional parameters, starting from one.  When
%%   the expansion occurs within double quotes, each parameter expands to
%%   a separate word.  That is, \texttt{"\$@"} is equivalent to
%%   \texttt{"\$1"} \texttt{"\$2"} \ldots\ \  When there are no positional
%%   parameters, \texttt{"\$@"} and \texttt{\$@} expand to nothing
%%   (i.e., they are removed).\\
%% %@+
%%   \$\# & Expands to the number of positional parameters in decimal.
%% \end{tabularx}

%% \section{\texttt{find}: an Extract from the GNU
%%   Documentation}
%% \label{apx:find-command}

%%    \texttt{\textbf{find}} searches for files in a directory hierarchy and prints
%% information about the files it found.  It is run like this:
%% \begin{verbatim}
%%      find [FILE...] [EXPRESSION]
%% \end{verbatim}

%% Here is a typical use of \textbf{\texttt{find}}.  This example prints the names of all
%% files in the directory tree rooted in `\texttt{/usr/src}' whose name ends with
%% `\texttt{.c}' and that are larger than 100 Kilobytes.
%% \begin{verbatim}
%%      find /usr/src -name '*.c' -size +100k -print
%% \end{verbatim}


%% \newcommand*{\MODE}{\emph{\texttt{\textbf{mode}}}\xspace}
%% \begin{description}
%%  \item[\texttt{Action: -ls}]
%%   True; list the current file in `\texttt{ls -dils}' format on the standard
%%   output.  The output looks like this:
%% {\footnotesize%
%% \begin{verbatim}
%% 204744   17 -rw-r--r--   1 djm      staff       17337 Nov  2  1992 ./lwall-quote
%% \end{verbatim}%
%% }
%%  \item[\texttt{Test: -perm \emph{mode}}] True if the file's permissions
%%   are exactly \MODE (which can be numeric or symbolic).  Symbolic
%%   modes use mode 0 as a point of departure.  If \MODE starts with
%%   `\texttt{-}', true if \emph{all} of the permissions set in \MODE are
%%   set for the file; permissions not set in \MODE are ignored.  If
%%   \MODE starts with `\texttt{+}', true if \emph{any} of the
%%   permissions set in \MODE are set for the file; permissions not set
%%   in \MODE are ignored.
  
%%   (Note that \vref{apx:file-permissions} shows how to specify file
%%   permissions.)
%% \end{description}
   
\section{Numeric File Permissions: an Excerpt from the
  GNU Documentation}
\label{apx:file-permissions}
   File permissions are stored internally as 16 bit integers.  As an
alternative to giving a symbolic mode, you can give an octal (base 8)
number that corresponds to the internal representation of the new mode.
This number is always interpreted in octal; you do not have to add a
leading 0, as you do in C.  Mode 0055 is the same as mode 55.

   A numeric mode is usually shorter than the corresponding symbolic
mode, but it is limited in that it can not take into account a file's
previous permissions; it can only set them absolutely.

   The permissions granted to the user, to other users in the file's
group, and to other users not in the file's group are each stored as
three bits, which are represented as one octal digit.  The three special
permissions are also each stored as one bit, and they are as a group
represented as another octal digit.  Here is how the bits are arranged
in the 16 bit integer, starting with the lowest valued bit:

\setlength{\extrarowheight}{0pt}
%@-
\begin{tabular}[t]{@{}rl@{}}
%@+
  \toprule%
  Value in  &Corresponding\\
  Mode     & Permission\\
  \midrule%
  &    Other users not in the file's group:\\
  1  &    Execute \\
  2  &    Write \\
  4  &    Read \\
  \midrule%
  &    Other users in the file's group:\\
  10  &    Execute \\
  20  &    Write \\
  40  &    Read \\
  \midrule%
  &    The file's owner: \\
  100  &    Execute \\
  200  &    Write \\
  400  &    Read \\
  \midrule%
  &    Special permissions: \\
  1000  &    Save text image on swap device \\
  2000  &    Set group ID on execution \\
  4000  &    Set user ID on execution \\
  \bottomrule
\end{tabular}

\bigskip   

   For example, numeric mode 4755 corresponds to symbolic mode
`\texttt{u=rwxs,go=rx}', and numeric mode 664 corresponds to symbolic mode
`\texttt{ug=rw,o=r}'.  Numeric mode 0 corresponds to symbolic mode `\texttt{ugo=}'.

%% \makeatletter
%% def\@listi{\leftmargin\leftmargini
%%             \parsep 5\p@  \@plus2.5\p@ \@minus\p@
%%             \topsep 10\p@ \@plus4\p@   \@minus6\p@
%%             \itemsep5\p@  \@plus2.5\p@ \@minus\p@}
%% \let\@listI\@listi
%% \def\@listii {\leftmargin\leftmarginii
%%               \labelwidth\leftmarginii
%%               \advance\labelwidth-\labelsep
%%               \topsep    5\p@   \@plus2.5\p@ \@minus\p@
%%               \parsep    2.5\p@ \@plus\p@    \@minus\p@
%%               \itemsep   \parsep}
%% \def\@listiii{\leftmargin\leftmarginiii
%%               \labelwidth\leftmarginiii
%%               \advance\labelwidth-\labelsep
%%               \topsep    2.5\p@\@plus\p@\@minus\p@
%%               \parsep    \z@
%%               \partopsep \p@ \@plus\z@ \@minus\p@
%%               \itemsep   \topsep}
%% \def\@listiv {\leftmargin\leftmarginiv
%%               \labelwidth\leftmarginiv
%%               \advance\labelwidth-\labelsep}
%% \makeatother


\section{\texttt{sed}: an Excerpt from Lecture Notes}
\label{apx:sed}
%@-
\makeatletter
\itemsep   15\p@   \@plus5\p@ \@minus2\p@
\makeatother
%@+
\enlargethispage*{2\baselineskip}
\textbf{\texttt{sed}---the Stream Editor}
  \begin{itemize*}
  \item \texttt{sed} provides many facilities for editing files
  \item \texttt{sed} reads from standard input and writes to standard output
  \item The \emph{substitute} command, \texttt{s///}, is the most
    important
  \item The syntax (using \texttt{sed} as an editor of standard input),
    is:
\begin{alltt}
$ \textbf{sed 's/\emph{original}/\emph{replacement}/'}
\end{alltt}%$
  \item Example: replace the first instance of \texttt{Windows} with
    \texttt{Linux} on each line of the input:
\begin{alltt}
 \textbf{sed 's/Windows/Linux/'}
\end{alltt}
  \item Example: replace \emph{all} instances of \texttt{Windows} with
    \texttt{Linux} on each line of the input:
\begin{alltt}
 \textbf{sed 's/Windows/Linux/g'}
\end{alltt}
\end{itemize*}

\section{Syntax of Some POSIX Commands}
\label{apx:syntax-of-posix-commands}

\begin{alltt}\Large
\textbf{find} [\meta{path}...] [\meta{expression}]
\end{alltt}
\texttt{find} searches the directory tree rooted at each \meta{path}
by evaluating \meta{expression} from left to right.  The first
argument that begins with `\texttt{-}', `\texttt{(}', `\texttt{)}',
`\texttt{,}', or `\texttt{!}' is taken to be the beginning of the
\meta{expression}; any arguments before it are \meta{path}s to search,
and any arguments after it are the rest of the \meta{expression}.

\paragraph{Expressions:}
The expression is made up of \emph{options} (which affect overall
operation rather than the processing of a specific file, and always
return true), \emph{tests} (which return a true or false value), and
\emph{actions} (which have side effects and return a true or false
value), all separated by operators.  \texttt{-and} is assumed where
the operator is omitted.  If the expression contains no actions,
\texttt{-print} is performed on all files for which the expression is
true.

\paragraph{Tests:}
\begin{description}
\item[\texttt{\textbf{-name} \meta{pattern}}] Base of file name (the
    path with the leading directories removed) matches shell pattern
    \meta{pattern}.
\end{description}

\paragraph{Actions:}

\begin{description}
  \makeatletter
  \itemsep    2.5\p@ \@plus\p@    \@minus\p@
  \makeatother
\item[\texttt{\textbf{-exec} \meta{command} \textbf{;}}]\mbox{\ }\\ Execute
  \meta{command}; true if 0 status is returned.  All following
  arguments to find are taken to be arguments to the command until an
  argument consisting of `\texttt{;}' is encountered.  The string
  `\texttt{\{\}}' is replaced by the current file name being
  processed.  Both of these constructions might need to be escaped
  (with a `\bs') or quoted to protect them from expansion by the
  shell.  The command is executed in the starting directory.
\item[\texttt{-print}] True; print the full file name on the standard
  output, followed by a newline.
\end{description}

\medskip

\begin{alltt}\label{pag:xargs}\Large
\textbf{xargs} [\meta{options}] [\meta{command} [\meta{initial-arguments}]]
\end{alltt}
\texttt{xargs} reads arguments from the standard input, delimited by
blanks (which can be protected with double or single quotes or a
backslash) or newlines, and executes the command (default is
\texttt{/bin/echo}) one or more times with any
\meta{initial-arguments} followed by arguments read from standard
input.  Blank lines on the standard input are ignored.
 
\paragraph{Options:}


\begin{description}
  \makeatletter
  \itemsep    2.5\p@ \@plus\p@    \@minus\p@
  \makeatother
\item[\texttt{--replace}, \texttt{-i}] Replace occurences of \{\} in
  the initial arguments with names read from standard input.  Also,
  unquoted blanks do not terminate arguments.
\end{description}

\medskip

\begin{alltt}\label{pag:grep}\Large
\textbf{egrep} [\meta{options}] \meta{pattern} [\meta{file}...]
\textbf{grep} [\meta{options}] \meta{pattern} [\meta{file}...]
\end{alltt}
 
\texttt{grep} searches the named input \meta{file}s (or standard input
if no files are named, or the file name - is given) for lines
containing a match to the given \meta{pattern}.  By default, grep
prints the matching lines.

\paragraph{Options:}
\begin{description}
  \makeatletter
  \itemsep    2.5\p@ \@plus\p@    \@minus\p@
  \makeatother
\item[\texttt{-E}, \texttt{--extended-regexp}] Interpret
  \meta{pattern} as an extended regular expression.  \texttt{egrep} is
  the same as \texttt{grep~-E}.
\item[\texttt{-c}, \texttt{--count}] Suppress normal output; instead
  print a count of matching lines for each input file.  With the
  \texttt{-v}, \texttt{--invert-match} option (see below), count
  non-matching lines.
\item[\texttt{-v}, \texttt{--invert-match}] Invert the sense of
  matching, to select non-matching lines.
\end{description}

\medskip

\begin{alltt}\Large
\textbf{sort} [\meta{option}...] [\meta{file}...]
\end{alltt}
Write sorted concatenation of all \meta{file}(s) to standard output.


\paragraph{Options:}
\begin{description}
  \makeatletter
  \itemsep    2.5\p@ \@plus\p@    \@minus\p@
  \makeatother
\item[\texttt{-b}, \texttt{--ignore-leading-blanks}] ignore leading
  blanks
\item[\texttt{-f}, \texttt{--ignore-case}] fold lower case to upper
  case characters
\item[\texttt{-k\meta{pos1}\textmd{[},\meta{pos2}\textmd{]}},
  \texttt{--key=\meta{pos1}\textmd{[},\meta{pos2}\textmd{]}}] start a
  key at \meta{pos1}, end it at \meta{pos2} (column numbers start with
  1)
\item[\texttt{-r}, \texttt{--reverse}] reverse the result of
  comparisons
\item[\texttt{-n}, \texttt{--numeric-sort}] compare according to
  string numerical value
\item[\texttt{-t} \meta{sep}, \texttt{--field-separator=}\meta{sep}] 
\end{description}

\medskip

\begin{alltt}\label{pag:diff}\Large
\textbf{diff} [\meta{options}] \meta{from-file} \meta{to-file}
\end{alltt}
In the simplest case, diff compares the contents of the two files
\meta{from-file} and \meta{to-file}.
\begin{description}
\item[\texttt{-u}] Use the unified output format.
\end{description}

\medskip

\begin{alltt}\label{pag:cut}\Large
\textbf{cut} [\meta{option}...] [\meta{file}...]
\end{alltt}
Print selected parts of lines from each FILE to standard output.

\begin{description}
  \makeatletter
  \itemsep    2.5\p@ \@plus\p@    \@minus\p@
  \makeatother
\item[\texttt{-b}, \texttt{--bytes=}\meta{list}] output only these
  bytes
\item[\texttt{-c}, \texttt{--characters=}\meta{list}] output only
  these characters
\item[\texttt{-d} \meta{delim}, \texttt{-delimiter=}\meta{delim}] use
  \meta{delim} instead of TAB for field delimiter
\item[\texttt{-f} \meta{list}, \texttt{--fields=}\meta{list}] output
  only these fields; also print any line that contains no delimiter
  character
\end{description}

Use one, and only one of \texttt{-b}, \texttt{-c} or \texttt{-f}.
Each \meta{list} is made up of one \emph{range}, or many \emph{ranges}
separated by commas.  Each \emph{range} is one of:
\begin{description}
  \makeatletter
  \itemsep    2.5\p@ \@plus\p@    \@minus\p@
  \makeatother
\item[\emph{N}]      \emph{N}th byte, character or field, counted from
  1
\item[\emph{N-}]     from \emph{N}th byte, character or field, to end
  of line
\item[\emph{N}\texttt{-}\emph{M}] from \emph{N}th to \emph{M}th
  (included) byte, character or field 
\item[\texttt{-}\emph{M}] from first to \emph{M}th (included) byte,
  character or field
\end{description}

\medskip

\begin{alltt}\label{pag:file}\Large
\textbf{file} [\meta{option}...] \meta{file}...
\end{alltt}
Identify the type of a file by examining the beginning of the file,
and comparing with patterns in the ``\emph{magic}'' file
\path{/usr/share/file/magic}.


\paragraph{Options:}

\begin{description}
  \makeatletter
  \itemsep    2.5\p@ \@plus\p@    \@minus\p@
  \makeatother
\item[\texttt{-b}] Do not prepend filenames to output lines (brief mode).
\end{description}


%% \medskip

%% \begin{alltt}\Large
%% \textbf{wc} [\meta{option}...] [\meta{file}...]
%% \end{alltt}
%% Print byte, word, and newline counts for each \meta{file}, and a total
%% line if more than one \meta{file} is specified.  With no \meta{file},
%% or when \meta{file} is \texttt{-}, read standard input.

%% \paragraph{Options:}

%% \begin{description}
%%   \makeatletter
%%   \itemsep    2.5\p@ \@plus\p@    \@minus\p@
%%   \makeatother
%% \item[\texttt{-c}, \texttt{--bytes}] print the byte counts
%% \item[\texttt{-l}, \texttt{--lines}] print the newline counts
%% \item[\texttt{-w}, \texttt{--words}] print the word count
%% \end{description}

\section{\texttt{awk}: an Excerpt from Lecture notes}
\label{apx:awk}
%@-
\makeatletter
\itemsep   15\p@   \@plus5\p@ \@minus2\p@
\makeatother
%@+
\textbf{{Basic \texttt{awk}}}
\begin{itemize*}
\item \texttt{awk} is a complete programming language
\item Mostly used for one-line solutions to problems of extracting
  columns of data from text, and processing it
\end{itemize*}

\textbf{{What Does \texttt{awk} Do?}}
\begin{itemize*}
\item \texttt{awk} reads file(s) or standard input one line at a
  time, and
\item automatically splits the line into fields, and calls them
  \texttt{\$1}, \texttt{\$2},\ldots, \texttt{\$NF}
\item \texttt{NF} is equal to the number of fields the line was
  split into
\item \texttt{\$0} contains the whole line
\item \texttt{awk} has an option \texttt{-F} that allows you to
  select another pattern as the field separator
  \begin{itemize*}
  \item Normally \texttt{awk} splits columns by white space
  \end{itemize*}
\item To execute code after all lines are processed, create an
  \texttt{END} block.
\end{itemize*}

\textbf{\texttt{awk} Examples}
\begin{itemize*}
\item Print the sizes of all files in current directory:
\begin{alltt}
$ \textbf{ls -l | awk '\{print $5\}'}
\end{alltt}
  \item Add the sizes of all files in current directory and print the size:
\begin{alltt}
$ \textbf{ls -l | awk '\{sum += $5\} END\{print sum\}'}
\end{alltt}
\item Print only the permissions, user, group and file names of files
  in current directory:
\begin{alltt}
$ \textbf{ls -l | awk '\{print $1, $3, $4, $NF\}'}
\end{alltt}%$
\end{itemize*}


\section{Extract from manual page for crontab file format}
\label{apx:crontab}

{% First change of parskip
  \setlength{\parskip}{0.6\baselineskip}

A \emph{crontab} file contains instructions to the cron(8) daemon of
the general form: ``run this command at this time on this date''.
Each user has their own crontab, and commands in any given crontab
will be executed as the user who owns the crontab.

Blank lines and leading spaces and tabs are ignored.  Lines whose
first non-space character is a pound-sign (\texttt{\#}) are comments, and are
ignored.  Note that comments are not allowed on the same line as cron
commands, since they will be taken to be part of the command.

cron(8) examines cron entries once every minute.
                                                                                   
The time and date fields are:
\par\medskip\par%
\begin{tabular}[t]{@{}ll@{}}
  \textbf{field} &  \textbf{allowed values}\\
  \midrule%
  minute        & 0--59\\
  hour          & 0--23\\
  day of month  & 1--31\\
  month         & 1--12 (or names, see below)\\
  day of week   & 0--7 (0 or 7 is Sun, or use names)
\end{tabular}
\par\medskip\par%
            
A field may be an asterisk (\texttt{*}), which always stands for ``first-last''.
                                                                                   
Ranges of numbers are allowed.  Ranges are two numbers separated with
a hyphen.  The specified range is inclusive.  For example,
\texttt{8-11} for an ``hours'' entry specifies execution at hours 8,
9, 10 and 11.
                                                                                   
Lists are allowed.  A list is a set of numbers (or ranges) separated
by commas.  Examples: ``\texttt{1,2,5,9}'', ``\texttt{0-4,8-12}''.
                                                                                   
Step values can be used in conjunction with ranges.  Following a range
with ``/\meta{number}'' specifies skips of the \meta{number}'s value
through the range.  For example, ``\texttt{0-23/2}'' can be used in
the hours field to specify command execution every other hour (the
alternative in the V7 standard is
``\texttt{0,2,4,6,8,10,12,14,16,18,20,22}'').  Steps are also
permitted after an asterisk, so if you want to say ``every two
hours'', just use ``\texttt{*/2}''.
                                                                                   
Names can also be used for the ``month'' and ``day of week'' fields.
Use the first three letters of the particular day or month (case
doesn't matter).  Ranges or lists of names are not allowed.
                                                                                   
The ``sixth'' field (the rest of the line) specifies the command to be
run.  The entire command portion of the line, up to a newline or \%
character, will be executed by \path{/bin/sh} or by the shell
specified in the \texttt{SHELL} variable of the cronfile.
Percent-signs (\texttt{\%}) in the command, unless escaped with
backslash (\bs), will be changed into newline characters, and all data
after the first \texttt{\%} will be sent to the command as standard
input.
                                                                                   
Note: The day of a command's execution can be specified by two fields
day of month, and day of week.  If both fields are restricted (ie,
aren't \texttt{*}), the command will be run when either field matches
the current time.  For example, ``\texttt{\mbox{30 4 1,15 * 5}}''
would cause a command to be run at 4.30\,am on the 1st and 15th of
each month, plus every Friday.


\paragraph{EXAMPLE CRON FILE}
\begin{verbatim}
# run five minutes after midnight, every day
5 0 * * *       $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
# run at 2:15pm on the first of every month
15 14 1 * *     $HOME/bin/monthly
# run at 10 pm on weekdays, annoy Joe
0 22 * * 1-5   mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"
5 4 * * sun     echo "run at 5 after 4 every sunday"
\end{verbatim}%$
}% End of first change of parskip.

\section{Examples of using rsync over SSH}
\label{apx:rsync-over-ssh-examples}
{% second change of parskip
  \setlength{\parskip}{0.6\baselineskip}

In these examples, the options \texttt{-avz} mean:
\begin{description}
  \makeatletter
  \itemsep    2.5\p@ \@plus\p@    \@minus\p@
  \makeatother
\item[\texttt{-a}, \texttt{--archive}] is a simple way of saying you
  want to copy recursively (i.e., all subdirectories), and preserve
  all permissions, ownerships and time stamps.
\item[\texttt{-v}, \texttt{--verbose}] increase the amount of
  information given; one \texttt{-v} will print the name of each file
  as it is transferred, and a brief summary at the end.
\item[\texttt{-z}, \texttt{--compress}] Compress the data sent to the
  destination.
\item[\texttt{-e ssh}] tells \texttt{rsync} to transfer the data over
  secure shell (\SSH).
\end{description}
To transfer content of directory, but not the directory itself, from
\path{/usr/src/} on the local machine to the directory
\path{/usr/local/sources} on host \path{ictlab}
\begin{alltt}
$ \texttt{rsync -avz -e ssh /usr/src/ ictlab:/usr/local/sources}
\end{alltt}%$
So for example, a file \path{/usr/src/file.c} on the local machine
will be transferred to the name \path{/usr/local/sources/file.c} on
the host \texttt{ictlab}.  Note the trailing slash on the source
directory name.

To transfer the directory \path{/usr/src} itself, from
the local machine to the directory
\path{/usr/local/sources} on host \path{ictlab}
\begin{alltt}
$ \texttt{rsync -avz -e ssh /usr/src ictlab:/usr/local/sources}
\end{alltt}%$
So for example, a file \path{/usr/src/file.c} on the local machine
will be transferred to the name \path{/usr/local/src/sources/file.c}
on the host \texttt{ictlab}.  Note there is no trailing slash on the
source directory name.
}% End of second change of parskip.


\section{Help Output for some \texttt{bash} Builtin Commands}
\label{sec:builtins-jc-trap}

\begin{alltt}\Large
\textbf{trap} [\meta{arg}] [\meta{signal spec} \ldots]
\end{alltt}

The command \meta{arg} is to be read and executed when the shell
receives signal(s) \meta{signal spec}.  If \meta{arg} is absent all
specified signals are reset to their original values.  If \meta{arg}
is the null string each \meta{signal spec} is ignored by the shell and
by the commands it invokes.  If a \meta{signal spec} is \texttt{EXIT}
(0) the command \meta{arg} is executed on exit from the shell.  If a
\meta{signal spec} is \texttt{DEBUG}, \meta{arg} is executed after
every command.  If \meta{arg} is `\texttt{-p}' then the trap commands
associated with each \meta{signal spec} are displayed.  If no
arguments are supplied or if only `\texttt{-p}' is given, trap prints
the list of commands associated with each signal number.  Each
\meta{signal spec} is either a signal name in \texttt{<signal.h>} or a
signal number.  Note that a signal can be sent to the shell with
``\texttt{kill -signal \$\$}''.

\begin{alltt}\Large
\textbf{jobs} [\textbf{-lnprs}] [\meta{jobspec} \ldots]
\end{alltt}
Lists the active jobs.  The \texttt{-l} option lists process \ID{}s in addition
to the normal information; the \texttt{-p} option lists process \ID{}s only.  If
\texttt{-n} is given, only processes that have changed status since the last
notification are printed.  \meta{jobspec} restricts output to that job.  The
\texttt{-r} and \texttt{-s} options restrict output to running and stopped jobs only,
respectively.  Without options, the status of all active jobs is
printed.

\begin{alltt}\Large
\textbf{fg} [\meta{jobspec}]
\end{alltt}
Place \meta{jobspec} in the foreground, and make it the current job.  If
\meta{jobspec} is not present, the shell's notion of the current job is
used.

\begin{alltt}\Large
\textbf{bg} [\meta{jobspec}]
\end{alltt}
Place \meta{jobspec} in the background, as if it had been started with
`\texttt{\&}'.  If \meta{jobspec} is not present, the shell's notion
of the current job is used.


\section{Regular Expression Metacharacters}
\label{apx:regexp}
                                                                                   
\begin{tabularx}{\linewidth}{@{}>{\ttfamily}lY@{}}
  \bs &   Quote the next metacharacter \\
  \textasciicircum &   Match the beginning of the line\\
  . &  Match any character (except newline)\\
  \$ &  Match the end of the line (or before newline at the end)\\
  \textbar &  Alternation\\
  (\ldots) & Grouping, and captures so that it can be used as a
  backreference\\
  {[\ldots]} & Character class \\
  {[\textasciicircum\ldots]} & Negated character class \\
  *   &   Match 0 or more times \\
  +   &   Match 1 or more times \\
  ?   &   Match 1 or 0 times \\
  \{$n$\} &   Match exactly $n$ times \\
  \{$n$,\} &  Match at least $n$ times \\
  \{$n$,$m$\} & Match at least $n$ but not more than $m$ times \\
 \end{tabularx}
\end{document}
