% Linux Installation and Getting Started    -*- TeX -*-
% commands.tex
% Copyright (c) 1992, 1993 by Matt Welsh, Larry Greenfield and Karl Fogel
%
% This file is freely redistributable, but you must preserve this copyright 
% notice on all copies, and it must be distributed only as part of "Linux 
% Installation and Getting Started". This file's use is covered by
% the copyright for the entire document, in the file "copyright.tex".

\section{Summary of Basic Commands}\label{sec-command-summ}

\index{commands!summary of basic|(}
This section introduces some of the most useful basic commands on a UNIX
system, including those covered in the last section. 

\index{commands!-@{\tt -} to begin options}
\index{-@{\tt -} to begin command options}
Note that options usually begin with a ``{\tt -}'', and in most cases multiple
one-letter options may be combined using a single ``{\tt -}''. For example,
instead of using the command {\tt ls -l -F}, it is adequate to use
{\tt ls -lF}.

Instead of listing all of the options available for each of these commands,
we'll only talk about those which are useful or important at this time.
In fact, most of these commands have a large number of options (most of which
you'll never use). You can use {\tt man} to see the manual pages for each
command, which list all of the available options.

Also note that many of these commands take a list of files or directories
as arguments, denoted by ``\cparam{file1} \ldots \cparam{fileN}''. For
example, the {\tt cp} command takes as arguments a list of files to copy,
followed by the destination file or directory. When copying more than one
file, the destination must be a directory.

\begin{dispitems}

\index{cd@{\tt cd}}
\ditem {{\tt cd}}
Change the current working directory. \\
Syntax: {\tt cd \cparam{directory}} \\
\cparam{directory} is the directory to change to. (``{\tt .}'' refers to the 
current directory, ``{\tt ..}'' the parent directory.)\\
Example: {\tt cd ../foo} sets the current directory to {\tt ../foo}.

\index{ls@{\tt ls}}
\ditem {{\tt ls}}
Displays information about the named files and directories. \\
Syntax: {\tt ls \cparam{file1} \cparam{file2} \ldots \cparam{fileN}} \\
Where \cparam{file1} through \cparam{fileN} are the filenames or directories
to list.
Options: There are more options than you want to think about. The most 
commonly used 
are {\tt -F} (used to display some information about the type of the file),
and {\tt -l} (gives a ``long'' listing including file size, owner, 
permissions, and so on. This will be covered in detail later.) \\
Example: {\tt ls -lF /home/larry} will display the contents of the directory
{\tt /home/larry}.

\index{cp@{\tt cp}}
\ditem {{\tt cp}} 
Copies file(s) to another file or directory. \\
Syntax: {\tt cp \cparam{file1} \cparam{file2} \ldots \cparam{fileN} 
\cparam{destination}} \\
Where \cparam{file1} through \cparam{fileN} are the files to copy, and
\cparam{destination} is the destination file or directory. \\
Example: {\tt cp ../frog joe} copies the file {\tt ../frog} to the file
or directory {\tt joe}.

\index{mv@{\tt mv}}
\ditem {{\tt mv}} 
Moves file(s) to another file or directory. This command does the 
equivalent of a copy followed by the deletion of the original. This
can be used to rename files, as in the MS-DOS command {\tt RENAME}. \\
Syntax: {\tt mv \cparam{file1} \cparam{file2} \ldots \cparam{fileN} 
\cparam{destination}} \\
Where \cparam{file1} through \cparam{fileN} are the files to move, and
\cparam{destination} is the destination file or directory. \\
Example: {\tt mv ../frog joe} moves the file {\tt ../frog} to the file
or directory {\tt joe}.


\index{rm@{\tt rm}}
\ditem {{\tt rm}} 
Deletes files. Note that when files are deleted under UNIX,
they are unrecoverable (unlike MS-DOS, where you can usually ``undelete''
the file). \\
Syntax: {\tt rm \cparam{file1} \cparam{file2} \ldots \cparam{fileN}}  \\
Where \cparam{file1} through \cparam{fileN} are the filenames to delete. \\
Options: {\tt -i} will prompt for confirmation before deleting the file. \\
Example: {\tt rm -i /home/larry/joe /home/larry/frog} deletes the files
{\tt joe} and {\tt frog} in {\tt /home/larry}.

\index{mkdir@{\tt mkdir}}
\ditem {{\tt mkdir}}
Creates new directories.\\
Syntax: {\tt mkdir \cparam{dir1} \cparam{dir2} \ldots \cparam{dirN}}  \\
Where \cparam{dir1} through \cparam{dirN} are the directories to create. \\
Example: {\tt mkdir /home/larry/test} creates the directory {\tt test}
under {\tt /home/larry}.

\index{rmdir@{\tt rmdir}}
\ditem {{\tt rmdir}} 
This command deletes empty directories. When using {\tt rmdir}, your
current working directory must not be within the directory to be deleted. \\
Syntax: {\tt rmdir \cparam{dir1} \cparam{dir2} \ldots \cparam{dirN}} \\
Where \cparam{dir1} through \cparam{dirN} are the directories to delete. \\
Example: {\tt rmdir /home/larry/papers} deletes the directory 
{\tt /home/larry/papers}, if it is empty.

\index{man@{\tt man}}
\ditem {{\tt man}} 
Displays the manual page for the given command or resource (that is,
any system utility which isn't a command, such as a library function.)
Syntax: {\tt man \cparam{command}} \\
Where \cparam{command} is the name of the command or resource to get help
on. \\
Example: {\tt man ls} gives help on the {\tt ls} command.

\index{more@{\tt more}}
\ditem {{\tt more}} 
Displays the contents of the named files, one screenful at a time. \\
Syntax: {\tt more \cparam{file1} \cparam{file2} \ldots \cparam{fileN}}  \\
Where \cparam{file1} through \cparam{fileN} are the files to display. \\
Example: {\tt more papers/history-final} displays the file
{\tt papers/history-final}.

\index{cat@{\tt cat}}
\ditem {{\tt cat}} 
Officially used to concatenate files, {\tt cat} is also used to display
the entire contents of a file at once.  \\
Syntax: {\tt cat \cparam{file1} \cparam{file2} \ldots \cparam{fileN}}  \\
Where \cparam{file1} through \cparam{fileN} are the files to display. \\
Example: {\tt cat letters/from-mdw} displays the file
{\tt letters/from-mdw}.

\index{echo@{\tt echo}}
\ditem{{\tt echo}}
Simply echoes the given arguments. \\
Syntax: {\tt echo \cparam{arg1} \cparam{arg2} \ldots \cparam{argN}}  \\
Where \cparam{arg1} through \cparam{argN} are the arguments to echo. \\
Example: {\tt echo "Hello world"} displays the string ``{\tt Hello world}''.

\index{grep@{\tt grep}}
\ditem{{\tt grep}}
Display all of the lines in the named file(s) matching the given pattern. \\
Syntax: {\tt grep \cparam{pattern} \cparam{file1} \cparam{file2} \ldots 
\cparam{fileN}}  \\
Where \cparam{pattern} is a regular expression pattern, and 
\cparam{file1} through \cparam{fileN} are the files to search.  \\
Example: {\tt grep loomer /etc/hosts} will display all lines in the file 
{\tt /etc/hosts} which contain the pattern ``{\tt loomer}''.  

\end{dispitems}

\index{commands!summary of basic|)}
