% $Id: chmod.tex 1.4 1998/01/11 21:06:58 brian Exp $

\chapter{chmod---Change File Mode}

The \textbf{chmod} command is an alternative to the ATTRIB command. It
allows you to change the attributes (file mode) of one or more files.
It can process hidden and system files in addition to ordinary files.

Unlike ATTRIB for DOS and OS/2, \textbf{chmod} treats a read-only file
as lacking the ``write'' capability rather than having the
``read-only'' capability.

The Win32 version of \textbf{chmod} will change the specified
attributes of matching directories. The DOS and OS/2 versions of
\textbf{chmod} ignore matching directories.

\section{Usage}

\verb~chmod [ -R ] [ +-= ][ wsha ] fpsec ...~
\medskip

If \texttt{-R} is specified, then \textbf{chmod} recursively descends
subdirectories looking for matching files. The \texttt{-R} flag is
compatible with the AIX and the original Unix versions of
\textbf{chmod}.

The first argument must contain exactly one of the ``\verb~+-=~'' file
mode operators followed by one or more of the ``\verb~wsha~'' file
mode letters, with no intervening spaces.

One or more file specifications must follow. A file specification
consists of some combination of drive, path, and filename. The
filename may contain Bourne shell pattern-matching characters.

The file mode operator can be one of the following:

% This should really be compact list
\begin{flushright}
    \begin{tabular}{l p{4.0in}}
    \texttt{+} & Sets the specified file mode(s). \\
    \texttt{-} & Resets the specified file mode(s). \\
    \texttt{=} & Sets the specified file mode(s) and clears the
                 modes that aren't specified.
    \end{tabular}
\end{flushright}

The file mode letters have the following meanings:

% Do I have to customize \parsep et al within the list environment
% or can I do it within the itemize environment? The following won't
% produce a compact list... should it? From "A Guide to LaTeX-2e",
% it looks like I'll have to redefine the enumerate and itemize
% lists as a new list environment and then fine-tune those to get
% the compact output.
% \begin{itemize}
% \setlength{\parsep}{0ex plus0.1ex minus0ex}
% \setlength{\itemsep}{0ex plus0.1ex minus0ex}
% 
%     \item[\texttt{w}]  Write permission.
%     \item[\texttt{s}]  System attribute.
%     \item[\texttt{h}]  Hidden attribute.
%     \item[\texttt{a}]  Archive attribute.
% 
% \end{itemize}

% This should really be compact list
\begin{flushright}
    \begin{tabular}{l p{4.0in}}
    \texttt{w} & Write permission.  \\
    \texttt{s} & System attribute.  \\
    \texttt{h} & Hidden attribute.  \\
    \texttt{a} & Archive attribute.
    \end{tabular}
\end{flushright}

\section{Examples}

\begin{enumerate}

\item \verb~chmod -w *~

                Reset the write permission for all of the files in the
                current directory, making them read-only.

\item \verb~chmod -R -w *~

                Reset the write permission for all of the files in
                the current directory and in all subdirectories,
                recursively.

\item \verb~chmod +ha *.exe~

                Make the \textbf{.exe} files in the current directory
                hidden, and set their archive bits.

\item \verb~chmod -a *.c~

                Reset the archive attribute for all of the \textbf{.c}
                files in the current directory.

\item \verb~chmod =sh /*~

                For all of the files in the root directory, set their
                system and hidden attributes and reset their write
                permission and archive attribute. When complete, the
                files will be unwritable (read-only), system, and hidden,
                and their archive attributes will be zero.

\end{enumerate}
