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

65 lines
4.0 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.13.2.1 The PATH environment variable</TITLE>
</HEAD>
<BODY>
<meta name="description" value="3.13.2.1 The PATH environment variable">
<meta name="keywords" value="gs">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
<BR> <HR><A NAME=tex2html3676 HREF="node153.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A> <A NAME=tex2html3674 HREF="node151.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A> <A NAME=tex2html3670 HREF="node151.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <A NAME=tex2html3678 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <A NAME=tex2html3679 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="index" SRC="index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html3677 HREF="node153.html">3.13.3 Shell initialization scripts</A>
<B>Up:</B> <A NAME=tex2html3675 HREF="node151.html">3.13.2 Shell variables and </A>
<B> Previous:</B> <A NAME=tex2html3671 HREF="node151.html">3.13.2 Shell variables and </A>
<BR> <HR> <P>
<H3><A NAME=SECTION005132100000000000000>3.13.2.1 The PATH environment variable</A></H3>
<P>
<A NAME=4149>&#160;</A>
When you use the <tt>ls</tt> command, how does the shell
find the <tt>ls</tt> executable itself? In fact, <tt>ls</tt> is found
in <tt>/bin/ls</tt> on most systems. The shell uses the environment variable
<tt>PATH</tt> to locate executable files for commands which you type.
<P>
For example, your <tt>PATH</tt> variable may be set to:
<P><TT> /bin:/usr/bin:/usr/local/bin:.
<P></TT>
This is a list of directories for the shell to search, each directory
separated by a ``<tt>:</tt>''. When you use the command <tt>ls</tt>, the
shell first looks for <tt>/bin/ls</tt>, then <tt>/usr/bin/ls</tt>, and so on.
<P>
Note that the <tt>PATH</tt> has nothing to do with finding regular files.
For example, if you use the command
<P><TT> /home/larry# <em>cp foo bar</em>
<P></TT>
The shell does not use <tt>PATH</tt> to locate the files <tt>foo</tt> and
<tt>bar</tt>---those filenames are assumed to be complete. The shell only
uses <tt>PATH</tt> to locate the <tt>cp</tt> executable.
<P>
This saves you a lot of time; it means that you don't have to remember where
all of the command executables are stored. On many systems, executables are
scattered about in many places, such as <tt>/usr/bin</tt>, <tt>/bin</tt>, or
<tt>/usr/local/bin</tt>. Instead of giving the command's full pathname (such
as <tt>/usr/bin/cp</tt>), you can simply set <tt>PATH</tt> to the list of
directories that you want the shell to automatically search.
<P>
Notice that <tt>PATH</tt> contains ``<tt>.</tt>'', which is the current working
directory. This allows you to create a shell script or program and run it as
a command from your current directory, without having
to specify it directly (as in <tt>./makebook</tt>). If a directory isn't on
your <tt>PATH</tt>, then the shell will not search it for commands to run---this
includes the current directory.
<P>
<BR> <HR><A NAME=tex2html3676 HREF="node153.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A> <A NAME=tex2html3674 HREF="node151.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A> <A NAME=tex2html3670 HREF="node151.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <A NAME=tex2html3678 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <A NAME=tex2html3679 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="index" SRC="index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html3677 HREF="node153.html">3.13.3 Shell initialization scripts</A>
<B>Up:</B> <A NAME=tex2html3675 HREF="node151.html">3.13.2 Shell variables and </A>
<B> Previous:</B> <A NAME=tex2html3671 HREF="node151.html">3.13.2 Shell variables and </A>
<BR> <HR> <P>
<BR> <HR>
<P><ADDRESS>
<I>Matt Welsh <BR>
mdw@sunsite.unc.edu</I>
</ADDRESS>
</BODY>