The Linux filesystem
There is no doubt that one of the most confusing things about Linux (at
least to the novice user) is its filesystem. Since most of us grew
accustomed to the way Windows does things, thinking about the filesystem
in terms of the A or C drive seems almost natural, but understanding the
differences between /etc and /var takes us to a whole different world. The
present article tries to make it easier for new Linux users to understand
the filesystem.
If you need more information, feel free to visit the
e.com/fhs/\">Filesystem Hierarchy Standard (FHS) site. This is the
organization that tries to lay out a filesystem standard not only for the
different Linux distributions, but also for UNIX.
So, here is a short list of the most important elements in the Linux
filesystem:
/
The root directory is considered to be the top of the whole filesystem both
in Linux and UNIX. To some extent, it is the equivalent of the C drive in
DOS and Windows. All other filesystems are under root, and this should
not be confused with the /root filesystem, which is
the home directory to the root account (the one used by the system
administrator).
/boot
This directory contains all the files that are necessary to boot up the
Linux operating system. These files are necessary to allocate memory and
mount all other filesystems. If you are still using older versions of
the Linux Loader (LILO), you\’d better make sure that this filesystem
falls within the 1024 limit otherwise your system will not be able to
boot at all. Since its size is can be quite small (around 30 Mb should
be more than enough), you can perfectly create a small partition for the
/boot filesystem close to the beginning of your hard drive
and then mount the rest from somewhere else. This tactic is particularly
useful if you need to share the hard drive with other operating systems,
such as Windows.
/dev
Another thing that is also difficult to understand for anyone who is
totally new to Linux or UNIX is that everything is a file in this
environment. Thus, the hardware devices are also mounted in the
regular filesystem, in this case in the /dev filesystem. Here
you will find basically all the hardware that you have, among many other
things: /dev/cdrom, /dev/fd0, /dev/hda1,
etc.
/etc
The /etc directory traditionally contains most of the system
configuration files: XF86Config and the whole /etc/X11 directory,
/etc/rc.d for initialization files, etc.
/home
The /home directory stores all files belonging to the multiple
users who have accounts on the system. By default, Linux also stores the
files for httpd and ftpd under the /home directory, which is something other flavors of UNIX do not do.
/lib
This directory contains all the system libraries that are used for the
Linux applications in order to run.
/lost+found
Whenever there is a crash in a Linux system, fsck will run
after you restart the system and will check for corrupted files. If it
finds anything, it will dump them here.
/mnt
This directory was created so that you could mount other external
filesystems here by default. Of course, you are totally free to mount
them wherever you wish, but this is the default directory created for that
purpose.
/opt
This optional directory is nothing but an inheritance of the
good old UNIX days, where all applications that did not come with the
operating system were installed here. Red Hat does not tend to use it
much, although there are certain applications that may want to install
there by default (Lotus Domino R5 for Linux being an example, and even
older versions of Corel Word Perfect, as far as I can remember).
/proc
The /proc filesystem is actually a virtual filesystem. It
does not actually use any space on your hard drive at all, and whenever
you run the df command you will notice that it is always
completely filled to 100 %. This is normal, since this directory is
used by the kernel to dynamically store information about how the
hardware is running. If you ever learn enough to check the source code
for those little applications that report things like memory usage, you
will notice that they usually read their information from this directory.
It is certainly a good idea to look around and see what sort of information
is held over here, but be extremely careful if you ever decide to change
anything.
/root
As mentioned somewhere above these lines, the /root directory
is nothing but the home directory for the root account. This is where
the system administrator or superuser may store personal files.
/sbin
The /sbin directory contains system binaries that are so
important to the normal operation of the OS that the system would
otherwise fail to boot without them.
/tmp
The are where your system will store temporary files. Many applications
will also save temporary files, which is fine except when they may store
information that is world readable and of personal character.
/usr
The /usr directory contains user binary files (i.e., those
binary files that are not specifically set aside in /sbin
for system use or for the root account). Perhaps of special interest is
the /usr/doc directory, where you will find plenty of
documentation on the software installed in your system.
/var
The /var directory keeps spooling, logging, and generic
data. You may find information such as the printer and mail spool
directories, the various PIDs of daemons that are running in the system
(in the /var/run directory most of the time), log files
from the mail daemon, the boot process, security messages, etc.






























