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

131 lines
6.1 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.3.2 Looking at the contents of directories</TITLE>
</HEAD>
<BODY>
<meta name="description" value="3.3.2 Looking at the contents of directories">
<meta name="keywords" value="gs">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
<BR> <HR><A NAME=tex2html3132 HREF="node109.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A> <A NAME=tex2html3130 HREF="node106.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A> <A NAME=tex2html3124 HREF="node107.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <A NAME=tex2html3134 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <A NAME=tex2html3135 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="index" SRC="index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html3133 HREF="node109.html">3.3.3 Creating new directories</A>
<B>Up:</B> <A NAME=tex2html3131 HREF="node106.html">3.3 First Steps into </A>
<B> Previous:</B> <A NAME=tex2html3125 HREF="node107.html">3.3.1 Moving around</A>
<BR> <HR> <P>
<H2><A NAME=SECTION00532000000000000000>3.3.2 Looking at the contents of directories</A></H2>
<A NAME=secls>&#160;</A>
<A NAME=2196>&#160;</A>
<A NAME=2356>&#160;</A>
<A NAME=2198>&#160;</A>
<A NAME=2199>&#160;</A>
Now that you know how to move around directories you probably think,
``So what?'' The basic skill of moving around directories is fairly
useless, so let's introduce a new command, <tt>ls</tt>. <tt>ls</tt> prints
a listing of files and directories, by default from your current
directory. For example:
<P>
<P><TT> /home/larry# <em>ls</em> <BR>
Mail <BR>
letters <BR>
papers <BR>
/home/larry#
<P></TT>
<P>
Here we can see that Larry has three entries in his current
directory: <tt>Mail</tt>, <tt>letters</tt>, and <tt>papers</tt>. This
doesn't tell us much---are these directories or files? We can use the
<tt>-F</tt> option on the <tt>ls</tt> command to tell us more.
<P>
<P><TT> /home/larry# <em>ls --F</em> <BR>
Mail/ <BR>
letters/ <BR>
papers/ <BR>
/home/larry#
<P></TT>
From the <tt>/</tt> appended to each filename, we know that these three
entries are in fact subdirectories.
<P>
<A NAME=2214>&#160;</A>
<A NAME=2215>&#160;</A>
Using <tt>ls -F</tt> may also append ``<tt>*</tt>'' to the end of a filename.
This indicates that the file is an <b>executable</b>, or a program which
can be run. If nothing is appended to the filename using <tt>ls -F</tt>, the
file is a ``plain old file'', that is, it's neither a directory, or an
executable.
<P>
In general, each UNIX command may take a number of options in addition
to other arguments. These options usually begin with a ``<tt>-</tt>'',
as demonstrated above with <tt>ls -F</tt>. The <tt>-F</tt> option tells <tt>ls</tt>
to give more information about the type of the files involved---in
this case, printing a <tt>/</tt> after each directory name.
<P>
If you give <tt>ls</tt> a directory name, it will print the contents of
that directory.
<P><TT> /home/larry# <em>ls --F papers</em> <BR>
english-lit <BR>
history-final <BR>
masters-thesis <BR>
notes/ <BR>
/home/larry#
<P></TT>
<P>
Or, for a more interesting listing, let's see what's in the
system's <tt>/etc</tt> directory.
<P>
<P><TT> /home/larry# <em>ls /etc</em>
<PRE>Images ftpusers lpc rc.new shells
adm getty magic rc0.d startcons
bcheckrc gettydefs motd rc1.d swapoff
brc group mount rc2.d swapon
brc~ inet mtab rc3.d syslog.conf
csh.cshrc init mtools rc4.d syslog.pid
csh.login init.d pac rc5.d syslogd.reload
default initrunlvl passwd rmt termcap
disktab inittab printcap rpc umount
fdprm inittab.old profile rpcinfo update
fstab issue psdatabase securetty utmp
ftpaccess lilo rc services wtmp
/home/larry#
</PRE> <P></TT>
<P>
(For those MS-DOS users out
there, notice how the filenames can be longer than 8 characters, and can
contain periods in any position. It is even possible to have more than one
period in a filename.)
<P>
Let's <tt>cd</tt> up to the top of the directory tree, using ``<tt>cd ..</tt>'',
and then down to another directory: <tt>/usr/bin</tt>.
<P>
<P><TT> /home/larry# <em>cd ..</em> <BR>
/home# <em>cd ..</em> <BR>
/# <em>cd usr</em> <BR>
/usr# <em>cd bin</em> <BR>
/usr/bin#
<P></TT>
You can also move into directories in multiple steps, as in <tt>cd /usr/bin</tt>.
<P>
Try moving around various directories, using <tt>ls</tt> and <tt>cd</tt>.
In some cases, you may run into a foreboding ``<tt>Permission denied</tt>''
error message. This is simply the concept of UNIX security kicking in:
in order to <tt>ls</tt> or to <tt>cd</tt> into a directory, you must have
permission to do so. We'll talk more about this in
<A NAME=2248>&#160;</A>
<A NAME=2357>&#160;</A>
<A NAME=2250>&#160;</A>
<A NAME=2251>&#160;</A>
Section <A HREF="node124.html#secfileperms">3.9</A>.
<P>
<BR> <HR><A NAME=tex2html3132 HREF="node109.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A> <A NAME=tex2html3130 HREF="node106.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A> <A NAME=tex2html3124 HREF="node107.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <A NAME=tex2html3134 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <A NAME=tex2html3135 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="index" SRC="index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html3133 HREF="node109.html">3.3.3 Creating new directories</A>
<B>Up:</B> <A NAME=tex2html3131 HREF="node106.html">3.3 First Steps into </A>
<B> Previous:</B> <A NAME=tex2html3125 HREF="node107.html">3.3.1 Moving around</A>
<BR> <HR> <P>
<BR> <HR>
<P><ADDRESS>
<I>Matt Welsh <BR>
mdw@sunsite.unc.edu</I>
</ADDRESS>
</BODY>