Files
oldlinux-files/docs/Install-Guide/install-guide-2.2.2/node99.html
2024-02-19 00:23:35 -05:00

108 lines
5.7 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.2.4 Shells and commands</TITLE>
</HEAD>
<BODY>
<meta name="description" value="3.2.4 Shells and commands">
<meta name="keywords" value="gs">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
<BR> <HR><A NAME=tex2html3018 HREF="node100.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A> <A NAME=tex2html3016 HREF="node95.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A> <A NAME=tex2html3010 HREF="node98.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <A NAME=tex2html3020 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <A NAME=tex2html3021 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="index" SRC="index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html3019 HREF="node100.html">3.2.5 Logging out</A>
<B>Up:</B> <A NAME=tex2html3017 HREF="node95.html">3.2 Basic UNIX Concepts</A>
<B> Previous:</B> <A NAME=tex2html3011 HREF="node98.html">3.2.3 Virtual consoles</A>
<BR> <HR> <P>
<H2><A NAME=SECTION00524000000000000000>3.2.4 Shells and commands</A></H2>
<A NAME=secshellscmds>&#160;</A>
<P>
<A NAME=1846>&#160;</A>
For most of your explorations in the world of UNIX, you'll be
talking to the system through the use of a <b>shell</b>.
A shell is just a program which takes user input (e.g., commands which
you type) and translates them into instructions. This can be compared
to the <tt>COMMAND.COM</tt> program under MS-DOS, which does essentially
the same thing. The shell is just one interface to UNIX. There are
many possible interfaces---such as the X Window System, which lets you
run commands by using the mouse and keyboard in conjunction.
<P>
As soon as you login, the system starts the shell, and you can type
commands to it. Here's a quick example. Here, Larry logs in, and is
left sitting at the shell <b>prompt</b>.
<P><TT> mousehouse login: <em>larry</em> <BR>
Password: <em>larry's password</em> <BR>
Welcome to Mousehouse! <BR>
<BR>
/home/larry#
<P></TT>
<A NAME=1854>&#160;</A>
``<tt>/home/larry#</tt>'' is the shell's prompt, indicating that it's
ready to take commands. (More on what the prompt itself means later.)
Let's try telling the system to do something interesting:
<P>
<P><TT> /home/larry# <em>make love</em> <BR>
make: *** No way to make target `love'. Stop. <BR>
/home/larry#
<P></TT>
<P>
Well, as it turns out <tt>make</tt> was the name of an actual program
on the system, and the shell executed this program when given the command.
(Unfortunately, the system was being unfriendly.)
<P>
<A NAME=1860>&#160;</A>
<A NAME=1861>&#160;</A>
<A NAME=1862>&#160;</A>
This brings us to one burning question: What are commands? What
happens when you type ``<tt>make love</tt>''? The first word on the command
line, ``<tt>make</tt>'', is the name of the command to be executed. Everything
else on the command line is taken as arguments to this command. Examples:
<P><TT> /home/larry# <em>cp foo bar</em>
<P></TT>
Here, the name of the command is ``<tt>cp</tt>'', and the arguments are
``<tt>foo</tt>'' and ``<tt>bar</tt>''.
<P>
When you type a command, the shell does several things. First of all, it
looks at the command name, and checks to see if it is a command which
is internal to the shell. (That is, a command which the shell knows how
to execute itself. There are a number of these commands, and we'll go
into them later.) The shell also checks to see if the command is an
alias, or substitute name, for another command. If neither of these conditions
apply, the shell looks for a program, on the disk, with the command's name.
If it finds such a program, the shell runs it, giving the program the
arguments specified on the command line.
<P>
In our example, the shell looks for the program called <tt>make</tt>, and
runs it with the argument <tt>love</tt>. <tt>Make</tt> is a program often used
to compile large programs, and it takes as arguments the name of a
``target'' to compile. In the case of ``<tt>make love</tt>'', we instructed
<tt>make</tt> to compile the target <tt>love</tt>. Because <tt>make</tt> can't
find a target by this name, it fails with a humorous error message, and
we are returned to the shell prompt.
<P>
<A NAME=2069>&#160;</A>
<A NAME=2070>&#160;</A>
What happens if we type a command to a shell, and the shell can't
find a program with the command name to run? Well, we can try it:
<P><TT> /home/larry# <em>eat dirt</em> <BR>
eat: command not found <BR>
/home/larry#
<P></TT>
Quite simply, if the shell can't find a program with the name given
on the command line (here, ``<tt>eat</tt>''), it prints an error message
which should be self-explanatory. You'll often see this error message
if you mistype a command (for example, if you had typed ``<tt>mkae love</tt>''
instead of ``<tt>make love</tt>'').
<P>
<BR> <HR><A NAME=tex2html3018 HREF="node100.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A> <A NAME=tex2html3016 HREF="node95.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A> <A NAME=tex2html3010 HREF="node98.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <A NAME=tex2html3020 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <A NAME=tex2html3021 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="index" SRC="index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html3019 HREF="node100.html">3.2.5 Logging out</A>
<B>Up:</B> <A NAME=tex2html3017 HREF="node95.html">3.2 Basic UNIX Concepts</A>
<B> Previous:</B> <A NAME=tex2html3011 HREF="node98.html">3.2.3 Virtual consoles</A>
<BR> <HR> <P>
<BR> <HR>
<P><ADDRESS>
<I>Matt Welsh <BR>
mdw@sunsite.unc.edu</I>
</ADDRESS>
</BODY>