THE LINUX FILESYSTEM
LAYOUT - GENERAL EXPLANATION
Many newcomers to linux have looked at the way it is laid out and
cringed. "It looks
so different to windows" is a common complaint. This is true, but thats
almost the
reason we want to move to linux is it not, it is not windows, linux
does in fact owe a
lot to it's unix heritage. But ranting aside, lets take a look at the
filesystem layout in general terms, and see if we cannot demystify it a
bit.
- /
This is the root
of the linux filesystem, it contains all the other directories.
This is also the first mounted directory, so if it cannot be found, the
the boot process will stall.
- /bin
As you may have guesses bin
is short for binaries,
and it is in this folder that
all the binaries/programs required for booting and using the system.
There should be no subdirectories in this directory.
- /boot
This is where everything is that happens before the kernel launches any
type of user mode
programs. There is the kernel image, the kernel configuration file,
grub has it's config
file here, etc. Changing things here unless you know what you're doing
is bad, thus
this directory should only be owned by root. A general security
recommendation is that
this directory should be on it's own little partition.
- /dev
Here dev
is short for devices,
it is here where all the different devices used by
your linux system reside as well as many more. There are literally
hundreds of files
here which correspond to your hardware. Like /dev/hda
is the device file for your first ide device. The devices in this
directory can mostly be put into two type of devices,
the first are block devices which are used to store data, these include
hard drives, cdrom's, etc. The second broad type of devices are
character devices which are used to transfer data, these include serial
ports, usb, firewaire, etc.
- /etc
A very important directory this one, and one to definetly back up. This
is where all
the system-realted configuration files are stored. This includes those
for the base system such as /etc/passwd
or /etc/resolv.conf
as well as for any packages which may be installed, such as /etc/samba/smb.conf
or /etc/ssh/sshd_config.
Be very careful of playing with the files here.
- /home
Pretty self-explanatory this one, this is the where all the users have
their home directories and where all of their files are saved by
default. Generally most systems
are setup in such a way that each user's directory is only usable by
that user. It
can also be very helpful to have this directory on its own partition.
Not only does
this make upgrading easier, but it also stops any user from using up
all the space
on your system disk with their files.
- /lib
Here lib
is short for libraries,
and it here that linux stores it's shared libraries,
which can be seen with the .so
extension. These files are needed by the system and many
of the tools used on the system. Certain folders hold the modules used
by the kernel itself.
Fiddle here only if you know what you're really sure you know what you
are doing.
- /mnt
The mount directory, which is shortened to mnt.
It is here where devices are generally mounted. Now mounting
is something which a lot of people new to linux struggle with. When
you mount a device you make it accessible to the system. Using mount
/dev/hda1 /mnt/data
will mount
the first partition of your first ide device /dev/hda1
to the directory /mnt/data,
so that anyone on your linux box wishing to access the data on this
partition
would look in /mnt/data.
You remove this mount
by using umount /mnt/dev/hda1.
If you want these mounts
to occur at startup add the information to /etc/fstab.
A lot of modern distributions will also do automounting, automatically
detecting any new devices and automatically mounting and unmounting
them. But I believe that it is
always a good idea to know what to do just in case.
- /opt
Optional software -not part of the standard install- generally goes
here. Each piece of software
will have it's own directory. This is also where software which has
been installed system-wide
goes.
- /proc
This directory allows you a real-time access window into the workings
of the kernel. The
files are generally all 0 bytes in size, but do have data contained
within them. The directory is therefore referred to as a Virtual
File System, as the files are
representations of different kernel configurations. You can view view
some, to see exactly what is happening on your server.
- /sbin
In sbin
are the binaries generally used by the systems administrator to carry
out their duties. The binaries here would be for things like creating
partiotions, or filesystems, etc. This could also be where certain
network daemons are installed to.
- /tmp
Also pretty self-explanatory this one, /tmp
is where any temporary files go. This
directory is specifically setup so that anyone can write to it, but
only the owners of the files in it can actually use them. Also, this
directory is generally cleaned up -everything
deleted- with each reboot.
- /usr
This is the home to all the user space binaries and the libraries,
documentation, etc that
go with them. For this reason /usr
occupies quite a bit of disk space. You will also
see that it has many subdirectories which are found off of the /
directory. All of
these contain user space application information.
- /var
In /var,
short for variables, is all non-static data. This includes log files,
mail
files, spool files, etc. The files in this directory are expected to be
constantly changing.
Well, thats it. Please be aware that
this is nothing but an overview. Things can and do change
from distribution to distribution. Also each of these directories could
have heaps more detailed
information written about them. But the above descriptions are a broad
map, which should help
you better find your way around, and help you understand, your linux
box.