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

360 lines
15 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.5 Exploring the File System</TITLE>
</HEAD>
<BODY>
<meta name="description" value="3.5 Exploring the File System">
<meta name="keywords" value="gs">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
<BR> <HR><A NAME=tex2html3226 HREF="node117.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A> <A NAME=tex2html3224 HREF="node93.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A> <A NAME=tex2html3218 HREF="node115.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <A NAME=tex2html3228 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <A NAME=tex2html3229 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="index" SRC="index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html3227 HREF="node117.html">3.6 Types of shells</A>
<B>Up:</B> <A NAME=tex2html3225 HREF="node93.html">3 Linux Tutorial</A>
<B> Previous:</B> <A NAME=tex2html3219 HREF="node115.html">3.4 Summary of Basic </A>
<BR> <HR> <P>
<H1><A NAME=SECTION00550000000000000000>3.5 Exploring the File System</A></H1>
<A NAME=secfilesystemtour>&#160;</A>
<P>
<A NAME=2544>&#160;</A>
The <b>file system</b> is the collection of files and the hierarchy of
directories on your system. I promised before to escort you around the
filesystem and the time has come.
<P>
You have the skills and the knowledge to make sense out of what
I'm saying, and you have a roadmap. (Refer to Figure <A HREF="node103.html#dirtree">3.2.8</A> on
page <A HREF="node103.html#dirtree"><IMG ALIGN=BOTTOM ALT="gif" SRC="cross_ref_motif.gif"></A>).
<P>
First, change to the root directory (<tt>cd /</tt>), and do an <tt>ls -F</tt>.
You'll probably see these directories<A NAME=tex2html443 HREF="footnode.html#2550"><IMG ALIGN=BOTTOM ALT="gif" SRC="foot_motif.gif"></A>: <tt>bin</tt>, <tt>
dev</tt>, <tt>etc</tt>, <tt>home</tt>, <tt>install</tt>, <tt>lib</tt>, <tt>mnt</tt>, <tt>
proc</tt>, <tt>root</tt>, <tt>tmp</tt>, <tt>user</tt>, <tt>usr</tt>, and <tt>var</tt>.
<P>
Let's take a look at each of these directories.
<P>
<DL COMPACT><A NAME=2786>&#160;</A>
<A NAME=2787>&#160;</A>
<DT><tt>/bin</tt>
<DD>
<tt>/bin</tt> is short for ``binaries'',
or executables. This is where many essential system programs reside.
Use the command ``<tt>ls -F /bin</tt>'' to list the files here.
If you look down the list you may see a few commands
that you recognize, such as <tt>cp</tt>, <tt>ls</tt>, and <tt>mv</tt>. These are
the actual programs for these commands. When you use the <tt>cp</tt> command,
you're running the program <tt>/bin/cp</tt>.
<P>
Using <tt>ls -F</tt>, you'll see that most (if not all) of the files in
<tt>/bin</tt> have an asterisk (``<tt>*</tt>'') appended to their filenames.
This indicates that the files are executables, as described in
Section <A HREF="node108.html#secls">3.3.2</A>.
<P>
<A NAME=2789>&#160;</A>
<A NAME=2790>&#160;</A>
<DT><tt>/dev</tt>
<DD>
Next on our stop is <tt>/dev</tt>. Take a look, again with
<tt>ls -F</tt>.
<P>
<A NAME=2584>&#160;</A>
<A NAME=2585>&#160;</A>
<A NAME=2586>&#160;</A>
The ``files'' in <tt>/dev</tt> are known as <b>device drivers</b>---they
are used to access system devices and resources, such as disk drives,
modems, memory, and so on. For example, just as you can read data from
a file, you can read input from the mouse by accessing <tt>/dev/mouse</tt>.
<P>
<A NAME=2792>&#160;</A>
<A NAME=2591>&#160;</A>
<A NAME=2592>&#160;</A>
The filenames beginning with <tt>fd</tt> are floppy disk devices. <tt>fd0</tt> is
the first floppy disk drive, <tt>fd1</tt> the second.
Now, the astute among you will notice that there are more floppy disk devices
then just the two I've listed above: they represent specific types of floppy
disks. For example, <tt>fd1H1440</tt> will access high-density, 3.5&quot;
diskettes in drive 1.
<P>
Here is a list of some of the most commonly used device files. Note that
even though you may not have some of the devices listed below, the chances
are that you'll have entries in <tt>/dev</tt> for them anyway.
<P>
<UL><A NAME=2599>&#160;</A>
<A NAME=2793>&#160;</A>
<A NAME=2601>&#160;</A>
<A NAME=2794>&#160;</A>
<LI> <tt>/dev/console</tt> refers to the system's console---that is, the
monitor connected directly to your system.
<P>
<A NAME=2604>&#160;</A>
<A NAME=2795>&#160;</A>
<A NAME=2796>&#160;</A>
<A NAME=2797>&#160;</A>
<A NAME=2798>&#160;</A>
<A NAME=2609>&#160;</A>
<LI> The various <tt>/dev/ttyS</tt> and <tt>/dev/cua</tt> devices are used
for accessing serial ports. For example, <tt>/dev/ttyS0</tt> refers to
``<tt>COM1</tt>'' under MS-DOS. The <tt>/dev/cua</tt> devices are ``callout''
devices, which are used in conjunction with a modem.
<P>
<A NAME=2615>&#160;</A>
<A NAME=2799>&#160;</A>
<A NAME=2800>&#160;</A>
<A NAME=2618>&#160;</A>
<LI> The device names beginning with <tt>hd</tt> access hard drives.
<tt>/dev/hda</tt> refers to the <em>whole</em> first hard disk, while <tt>hda1</tt>
refers to the first <em>partition</em> on <tt>/dev/hda</tt>.
<P>
<A NAME=2625>&#160;</A>
<A NAME=2626>&#160;</A>
<A NAME=2801>&#160;</A>
<A NAME=2802>&#160;</A>
<A NAME=2803>&#160;</A>
<A NAME=2804>&#160;</A>
<A NAME=2805>&#160;</A>
<A NAME=2806>&#160;</A>
<LI> The device names beginning with <tt>sd</tt> are SCSI drives.
If you have a SCSI hard drive, instead of accessing it through
<tt>/dev/hda</tt>, you would access <tt>/dev/sda</tt>. SCSI tapes are
accessed via <tt>st</tt> devices, and SCSI CD-ROM via <tt>sr</tt> devices.
<P>
<A NAME=2638>&#160;</A>
<A NAME=2807>&#160;</A>
<A NAME=2808>&#160;</A>
<A NAME=2641>&#160;</A>
<LI> The device names beginning with <tt>lp</tt> access parallel ports.
<tt>/dev/lp0</tt> refers to ``<tt>LPT1</tt>'' in the MS-DOS world.
<P>
<A NAME=2645>&#160;</A>
<A NAME=2809>&#160;</A>
<A NAME=2810>&#160;</A>
<A NAME=2648>&#160;</A>
<LI> <tt>/dev/null</tt> is used as a ``black hole''---any data sent to
this device is gone forever. Why is this useful? Well, if you wanted to
suppress the output of a command appearing on your screen, you could
send that output to <tt>/dev/null</tt>. We'll talk more about this later.
<P>
<A NAME=2651>&#160;</A>
<A NAME=2811>&#160;</A>
<A NAME=2812>&#160;</A>
<A NAME=2654>&#160;</A>
<LI> The device names beginning with <tt>/dev/tty</tt> refer to the
``virtual consoles'' on your system (accessed via by pressing
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img169.gif">, <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img170.gif">, and so on). <tt>/dev/tty1</tt> refers to the
first VC, <tt>/dev/tty2</tt> refers to the second, and so on.
<P>
<A NAME=2660>&#160;</A>
<A NAME=2813>&#160;</A>
<A NAME=2662>&#160;</A>
<A NAME=2814>&#160;</A>
<LI> The device names beginning with <tt>/dev/pty</tt> are ``pseudo-terminals''.
They are used to provide a ``terminal'' to remote login sessions. For
example, if your machine is on a network, incoming <tt>telnet</tt> logins would
use one of the <tt>/dev/pty</tt> devices.
</UL>
<P>
<A NAME=2815>&#160;</A>
<A NAME=2816>&#160;</A>
<DT><tt>/etc</tt>
<DD>
<tt>/etc</tt> contains a number of miscellaneous system configuration files.
These include <tt>/etc/passwd</tt> (the user database), <tt>/etc/rc</tt>
(the system initialization script), and so on.
<P>
<A NAME=2818>&#160;</A>
<A NAME=2819>&#160;</A>
<DT><tt>/sbin</tt>
<DD>
<tt>sbin</tt> is used for storing essential system binaries, to be used
by the system administrator.
<P>
<A NAME=2821>&#160;</A>
<A NAME=2822>&#160;</A>
<DT><tt>/home</tt>
<DD>
<tt>/home</tt> contains user's home directories. For example, <tt>/home/larry</tt>
is the home directory for the user ``<tt>larry</tt>''. On a newly-installed
system, there may not be any users in this directory.
<P>
<A NAME=2824>&#160;</A>
<A NAME=2825>&#160;</A>
<DT><tt>/lib</tt>
<DD>
<tt>/lib</tt> contains <b>shared library images</b>. These files contain
code which many programs share in common. Instead of each program
containing its own copy of these shared routines, they are all stored
in one common place, in <tt>/lib</tt>. This makes executable files smaller,
and saves space on your system.
<P>
<A NAME=2827>&#160;</A>
<A NAME=2828>&#160;</A>
<DT><tt>/proc</tt>
<DD>
<tt>/proc</tt> is a ``virtual filesystem'', the files in which are stored
in memory, not on the drive. They refer to the various <b>processes</b> running
on the system, and allow you to get information about what programs and
processes are running at any given time. We'll go into more detail in
Section <A HREF="node133.html#secprocess">3.11.1</A>.
<P>
<A NAME=2830>&#160;</A>
<A NAME=2831>&#160;</A>
<DT><tt>/tmp</tt>
<DD>
Many programs have a need to generate some information and store it in
a temporary file. The canonical location for these files is in <tt>/tmp</tt>.
<P>
<A NAME=2833>&#160;</A>
<A NAME=2834>&#160;</A>
<DT><tt>/usr</tt>
<DD>
<tt>/usr</tt> is a very important directory. It contains a number of
subdirectories which in turn contain some of the most important and
useful programs and configuration files used on the system.
<P>
The various directories described above are essential for the system
to operate, but most of the things found in <tt>/usr</tt> are optional
for the system. However, it is those optional things which make the
system useful and interesting. Without <tt>/usr</tt>, you'd more or less
have a boring system, only with programs like <tt>cp</tt> and <tt>ls</tt>.
<tt>/usr</tt> contains most of the larger software packages and the
configuration files which accompany them.
<P>
<A NAME=2836>&#160;</A>
<A NAME=2837>&#160;</A>
<DT><tt>/usr/X386</tt>
<DD>
<tt>/usr/X386</tt> contains The X Window System, if you installed it.
The X Window System is a large, powerful graphical environment which
provides a large number of graphical utilities and programs, displayed
in ``windows'' on your screen. If you're at all familiar with the
Microsoft Windows or Macintosh environments, X Windows will look very
familiar. The <tt>/usr/X386</tt> directory contains all of the X Windows
executables, configuration files, and support files. This will be
covered in more detail in Section <A HREF="node198.html#secxwindows">5.1</A>.
<P>
<A NAME=2839>&#160;</A>
<DT><tt>/usr/bin</tt>
<DD>
<tt>/usr/bin</tt> is the real warehouse for software on any UNIX system.
It contains most of the executables for programs not found in other
places, such as <tt>/bin</tt>.
<P>
<A NAME=2841>&#160;</A>
<A NAME=2842>&#160;</A>
<DT><tt>/usr/etc</tt>
<DD>
Just as <tt>/etc</tt> contained miscellaneous system programs and configuration
files, <tt>/usr/etc</tt> contains even more of these utilities and files.
In general, the files found in <tt>/usr/etc</tt> are not essential to the
system, unlike those found in <tt>/etc</tt>, which are.
<P>
<A NAME=2844>&#160;</A>
<A NAME=2845>&#160;</A>
<DT><tt>/usr/include</tt>
<DD>
<tt>/usr/include</tt> contains <b>include files</b> for the C compiler.
These files (most of which end in <tt>.h</tt>, for ``header'') declare
data structure names, subroutines, and constants used when writing programs
in C. Those files found in <tt>/usr/include/sys</tt> are generally used
when programming on the UNIX system level. If you are familiar with
the C programming language, here you'll find header files such as
<tt>stdio.h</tt>, which declares functions such as <tt>printf()</tt>.
<P>
<A NAME=2847>&#160;</A>
<A NAME=2848>&#160;</A>
<DT><tt>/usr/g++-include</tt>
<DD>
<tt>/usr/g++-include</tt> contains include files for the C++ compiler (much
like <tt>/usr/include</tt>).
<P>
<A NAME=2850>&#160;</A>
<A NAME=2851>&#160;</A>
<DT><tt>/usr/lib</tt>
<DD>
<tt>/usr/lib</tt> contains the ``stub'' and ``static'' library equivalents
to the files found in <tt>/lib</tt>. When compiling a program, the program
is ``linked'' with the libraries found in <tt>/usr/lib</tt>, which then directs
the program to look in <tt>/lib</tt> when it needs the actual code in the
library. In addition, various other programs store configuration files in
<tt>/usr/lib</tt>.
<P>
<A NAME=2853>&#160;</A>
<A NAME=2854>&#160;</A>
<DT><tt>/usr/local</tt>
<DD>
<tt>/usr/local</tt> is a lot like <tt>/usr</tt>---it contains various programs
and files not essential to the system, but which make the system fun
and exciting. In general, those programs found in <tt>/usr/local</tt> are
specialized for your system specifically---that is, <tt>/usr/local</tt>
differs greatly between UNIX systems.
<P>
Here, you'll find large software packages such as <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img171.gif"> (a document
formatting system) and Emacs (a large and powerful editor), if you
installed them.
<P>
<A NAME=2856>&#160;</A>
<A NAME=2857>&#160;</A>
<DT><tt>/usr/man</tt>
<DD>
This directory contains the actual man pages. There are two subdirectories
for every man page ``section'' (use the command <tt>man man</tt> for details).
For example, <tt>/usr/man/man1</tt> contains the source (that is,
the unformatted original) for man pages in section 1, and <tt>/usr/man/cat1</tt>
contains the formatted man pages for section 1.
<P>
<A NAME=2859>&#160;</A>
<A NAME=2860>&#160;</A>
<DT><tt>/usr/src</tt>
<DD>
<tt>/usr/src</tt> contains the source code (the uncompiled program) for various
programs on your system. The most important thing here is <tt>/usr/src/linux</tt>,
which contains the source code for the Linux kernel.
<P>
<A NAME=2862>&#160;</A>
<A NAME=2863>&#160;</A>
<DT><tt>/var</tt>
<DD>
<tt>/var</tt> holds directories that often change in size or tend to grow.
Many of those directories used to reside in <tt>/usr</tt>, but since we
are trying to keep it relatively unchangeable, the directories that
change often have been moved to <tt>/var</tt>.
Some of those directories are:
<P>
<A NAME=2865>&#160;</A>
<A NAME=2866>&#160;</A>
<DT><tt>/var/adm</tt>
<DD>
<tt>/var/adm</tt> contains various files of interest to the system
administrator, specifically system logs, which record any errors or
problems with the system. Other files record logins to the system, as
well as failed login attempts. This will be covered in
Chapter <A HREF="node155.html#chapsysadm">4</A>.
<P>
<A NAME=2868>&#160;</A>
<A NAME=2869>&#160;</A>
<DT><tt>/var/spool</tt>
<DD>
<tt>/var/spool</tt> contains files which are to be ``spooled'' to another
program. For example, if your machine is connected to a network, incoming
mail will be stored in <tt>/var/spool/mail</tt>, until you read it or
delete it. Outgoing or incoming news articles may be found
in <tt>/var/spool/news</tt>, and so on.
<P>
</DL>
<A NAME=2784>&#160;</A>
<P>
<BR> <HR><A NAME=tex2html3226 HREF="node117.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A> <A NAME=tex2html3224 HREF="node93.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A> <A NAME=tex2html3218 HREF="node115.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <A NAME=tex2html3228 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <A NAME=tex2html3229 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="index" SRC="index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html3227 HREF="node117.html">3.6 Types of shells</A>
<B>Up:</B> <A NAME=tex2html3225 HREF="node93.html">3 Linux Tutorial</A>
<B> Previous:</B> <A NAME=tex2html3219 HREF="node115.html">3.4 Summary of Basic </A>
<BR> <HR> <P>
<BR> <HR>
<P><ADDRESS>
<I>Matt Welsh <BR>
mdw@sunsite.unc.edu</I>
</ADDRESS>
</BODY>