185 lines
11 KiB
HTML
185 lines
11 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
|
|
<!Converted with LaTeX2HTML 95.1 (Fri Jan 20 1995) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
|
|
<HEAD>
|
|
<TITLE>3.4 Summary of Basic Commands</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<meta name="description" value="3.4 Summary of Basic Commands">
|
|
<meta name="keywords" value="gs">
|
|
<meta name="resource-type" value="document">
|
|
<meta name="distribution" value="global">
|
|
<P>
|
|
<BR> <HR><A NAME=tex2html3214 HREF="node116.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A> <A NAME=tex2html3212 HREF="node93.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A> <A NAME=tex2html3206 HREF="node114.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <A NAME=tex2html3216 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <A NAME=tex2html3217 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="index" SRC="index_motif.gif"></A> <BR>
|
|
<B> Next:</B> <A NAME=tex2html3215 HREF="node116.html">3.5 Exploring the File </A>
|
|
<B>Up:</B> <A NAME=tex2html3213 HREF="node93.html">3 Linux Tutorial</A>
|
|
<B> Previous:</B> <A NAME=tex2html3207 HREF="node114.html">3.3.8 Getting online help</A>
|
|
<BR> <HR> <P>
|
|
<H1><A NAME=SECTION00540000000000000000>3.4 Summary of Basic Commands</A></H1>
|
|
<A NAME=seccommandsumm> </A>
|
|
<P>
|
|
<A NAME=2368> </A>
|
|
This section introduces some of the most useful basic commands on a UNIX
|
|
system, including those covered in the last section.
|
|
<P>
|
|
<A NAME=2504> </A>
|
|
<A NAME=2505> </A>
|
|
Note that options usually begin with a ``<tt>-</tt>'', and in most cases multiple
|
|
one-letter options may be combined using a single ``<tt>-</tt>''. For example,
|
|
instead of using the command <tt>ls -l -F</tt>, it is adequate to use
|
|
<tt>ls -lF</tt>.
|
|
<P>
|
|
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</tt> to see the manual pages for each
|
|
command, which list all of the available options.
|
|
<P>
|
|
Also note that many of these commands take a list of files or directories
|
|
as arguments, denoted by ``<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img107.gif"> ...<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img108.gif">''. For
|
|
example, the <tt>cp</tt> 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.
|
|
<P>
|
|
<DL COMPACT><A NAME=2506> </A>
|
|
<DT><tt>cd</tt>
|
|
<DD>
|
|
Change the current working directory. <BR>
|
|
Syntax: <tt>cd <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img109.gif"></tt> <BR>
|
|
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img110.gif"> is the directory to change to. (``<tt>.</tt>'' refers to the
|
|
current directory, ``<tt>..</tt>'' the parent directory.)<BR>
|
|
Example: <tt>cd ../foo</tt> sets the current directory to <tt>../foo</tt>.
|
|
<P>
|
|
<A NAME=2509> </A>
|
|
<DT><tt>ls</tt>
|
|
<DD>
|
|
Displays information about the named files and directories. <BR>
|
|
Syntax: <tt>ls <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img111.gif"> <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img112.gif"> ...<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img113.gif"></tt> <BR>
|
|
Where <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img114.gif"> through <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img115.gif"> 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</tt> (used to display some information about the type of the file),
|
|
and <tt>-l</tt> (gives a ``long'' listing including file size, owner,
|
|
permissions, and so on. This will be covered in detail later.) <BR>
|
|
Example: <tt>ls -lF /home/larry</tt> will display the contents of the directory
|
|
<tt>/home/larry</tt>.
|
|
<P>
|
|
<A NAME=2512> </A>
|
|
<DT><tt>cp</tt>
|
|
<DD>
|
|
Copies file(s) to another file or directory. <BR>
|
|
Syntax: <tt>cp <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img116.gif"> <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img117.gif"> ...<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img118.gif">
|
|
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img119.gif"></tt> <BR>
|
|
Where <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img120.gif"> through <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img121.gif"> are the files to copy, and
|
|
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img122.gif"> is the destination file or directory. <BR>
|
|
Example: <tt>cp ../frog joe</tt> copies the file <tt>../frog</tt> to the file
|
|
or directory <tt>joe</tt>.
|
|
<P>
|
|
<A NAME=2515> </A>
|
|
<DT><tt>mv</tt>
|
|
<DD>
|
|
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</tt>. <BR>
|
|
Syntax: <tt>mv <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img123.gif"> <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img124.gif"> ...<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img125.gif">
|
|
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img126.gif"></tt> <BR>
|
|
Where <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img127.gif"> through <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img128.gif"> are the files to move, and
|
|
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img129.gif"> is the destination file or directory. <BR>
|
|
Example: <tt>mv ../frog joe</tt> moves the file <tt>../frog</tt> to the file
|
|
or directory <tt>joe</tt>.
|
|
<P>
|
|
<A NAME=2518> </A>
|
|
<DT><tt>rm</tt>
|
|
<DD>
|
|
Deletes files. Note that when files are deleted under UNIX,
|
|
they are unrecoverable (unlike MS-DOS, where you can usually ``undelete''
|
|
the file). <BR>
|
|
Syntax: <tt>rm <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img130.gif"> <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img131.gif"> ...<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img132.gif"></tt> <BR>
|
|
Where <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img133.gif"> through <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img134.gif"> are the filenames to delete. <BR>
|
|
Options: <tt>-i</tt> will prompt for confirmation before deleting the file. <BR>
|
|
Example: <tt>rm -i /home/larry/joe /home/larry/frog</tt> deletes the files
|
|
<tt>joe</tt> and <tt>frog</tt> in <tt>/home/larry</tt>.
|
|
<P>
|
|
<A NAME=2521> </A>
|
|
<DT><tt>mkdir</tt>
|
|
<DD>
|
|
Creates new directories.<BR>
|
|
Syntax: <tt>mkdir <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img135.gif"> <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img136.gif"> ...<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img137.gif"></tt> <BR>
|
|
Where <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img138.gif"> through <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img139.gif"> are the directories to create. <BR>
|
|
Example: <tt>mkdir /home/larry/test</tt> creates the directory <tt>test</tt>
|
|
under <tt>/home/larry</tt>.
|
|
<P>
|
|
<A NAME=2524> </A>
|
|
<DT><tt>rmdir</tt>
|
|
<DD>
|
|
This command deletes empty directories. When using <tt>rmdir</tt>, your
|
|
current working directory must not be within the directory to be deleted. <BR>
|
|
Syntax: <tt>rmdir <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img140.gif"> <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img141.gif"> ...<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img142.gif"></tt> <BR>
|
|
Where <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img143.gif"> through <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img144.gif"> are the directories to delete. <BR>
|
|
Example: <tt>rmdir /home/larry/papers</tt> deletes the directory
|
|
<tt>/home/larry/papers</tt>, if it is empty.
|
|
<P>
|
|
<A NAME=2527> </A>
|
|
<DT><tt>man</tt>
|
|
<DD>
|
|
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 <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img145.gif"></tt> <BR>
|
|
Where <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img146.gif"> is the name of the command or resource to get help
|
|
on. <BR>
|
|
Example: <tt>man ls</tt> gives help on the <tt>ls</tt> command.
|
|
<P>
|
|
<A NAME=2530> </A>
|
|
<DT><tt>more</tt>
|
|
<DD>
|
|
Displays the contents of the named files, one screenful at a time. <BR>
|
|
Syntax: <tt>more <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img147.gif"> <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img148.gif"> ...<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img149.gif"></tt> <BR>
|
|
Where <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img150.gif"> through <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img151.gif"> are the files to display. <BR>
|
|
Example: <tt>more papers/history-final</tt> displays the file
|
|
<tt>papers/history-final</tt>.
|
|
<P>
|
|
<A NAME=2533> </A>
|
|
<DT><tt>cat</tt>
|
|
<DD>
|
|
Officially used to concatenate files, <tt>cat</tt> is also used to display
|
|
the entire contents of a file at once. <BR>
|
|
Syntax: <tt>cat <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img152.gif"> <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img153.gif"> ...<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img154.gif"></tt> <BR>
|
|
Where <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img155.gif"> through <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img156.gif"> are the files to display. <BR>
|
|
Example: <tt>cat letters/from-mdw</tt> displays the file
|
|
<tt>letters/from-mdw</tt>.
|
|
<P>
|
|
<A NAME=2536> </A>
|
|
<DT><tt>echo</tt>
|
|
<DD>
|
|
Simply echoes the given arguments. <BR>
|
|
Syntax: <tt>echo <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img157.gif"> <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img158.gif"> ...<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img159.gif"></tt> <BR>
|
|
Where <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img160.gif"> through <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img161.gif"> are the arguments to echo. <BR>
|
|
Example: <tt>echo "Hello world"</tt> displays the string ``<tt>Hello world</tt>''.
|
|
<P>
|
|
<A NAME=2539> </A>
|
|
<DT><tt>grep</tt>
|
|
<DD>
|
|
Display all of the lines in the named file(s) matching the given pattern. <BR>
|
|
Syntax: <tt>grep <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img162.gif"> <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img163.gif"> <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img164.gif"> ...
|
|
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img165.gif"></tt> <BR>
|
|
Where <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img166.gif"> is a regular expression pattern, and
|
|
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img167.gif"> through <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img168.gif"> are the files to search. <BR>
|
|
Example: <tt>grep loomer /etc/hosts</tt> will display all lines in the file
|
|
<tt>/etc/hosts</tt> which contain the pattern ``<tt>loomer</tt>''.
|
|
<P>
|
|
</DL>
|
|
<P>
|
|
<A NAME=2503> </A>
|
|
<P>
|
|
<BR> <HR><A NAME=tex2html3214 HREF="node116.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A> <A NAME=tex2html3212 HREF="node93.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A> <A NAME=tex2html3206 HREF="node114.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <A NAME=tex2html3216 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <A NAME=tex2html3217 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="index" SRC="index_motif.gif"></A> <BR>
|
|
<B> Next:</B> <A NAME=tex2html3215 HREF="node116.html">3.5 Exploring the File </A>
|
|
<B>Up:</B> <A NAME=tex2html3213 HREF="node93.html">3 Linux Tutorial</A>
|
|
<B> Previous:</B> <A NAME=tex2html3207 HREF="node114.html">3.3.8 Getting online help</A>
|
|
<BR> <HR> <P>
|
|
<BR> <HR>
|
|
<P><ADDRESS>
|
|
<I>Matt Welsh <BR>
|
|
mdw@sunsite.unc.edu</I>
|
|
</ADDRESS>
|
|
</BODY>
|