Revision / Modified: Apr. 20, 2002
Author: Tom Berger
http://www.mandrakeuser.org/docs/basics/bfiles.html http://www.mandrakeuser.org/docs/basics/bfiles2.html http://www.mandrakeuser.org/docs/basics/bfiles3.html http://www.mandrakeuser.org/docs/basics/bfiles4.html
Operation systems of the Unix family feature a file system order that is
Hierarchy here means that the directory tree is indeed one tree.
Directories follow a designed order starting from the root directory ('/')
instead of having so-called 'drives'.
Within MS Windows, you may put your files (almost) anywhere: on 'C', 'D', 'E' etc. Hierarchical structures are managed by the programs themselves ('program directories') and not by the operating system.
Unix (and therefore Linux) on the other hand sorts directories ascending from the root directory '/' according to their importance for the boot process. And here it is the operating system that determines into which directories programs have to put their files into. Directories are not program- but function-specific.
If you install a program in MS Windows, it usually stores most of its files
in its own directory structure. A help file for instance may be in 'program
name\' or in 'program_name\help' or in 'program
In Linux, programs put their documentation into '/usr/share/doc/program_name', man pages into '/usr/share/man/man[1-9]', info pages into '/usr/share/info'.That is they are merged with the system hierarchy.
One reason for this arrangement is that a centralized file system hierarchy is much easier to administer. For instance changes on one machine can be easily transferred to the clients on the network.
A consequence of this structure is the concept of partition mounts which usually confuses new users. All GNU/Linux partitions on your hard drive are mounted to ('hooked into') mount directories (aka 'mount points'). And you access them via these directories ('/' or '/usr' or '/mnt/cdrom' etc). This assures a seamless integration into the system, regardless if the mount is a local partition or one on the network server. And the mount names stay the same, if there are partitions or external media mounted to them or not. In contrast to Windows, where an additional local 'drive letter' changes all the 'drive letters' behind it and networked partitions are handled as extra 'drives'.
Another reason is that Linux caches a lot of disk accesses using
system memory while it is running to accelerate these accesses.
It is therefore vitally important that these buffers are 'flushed' (i.e. get their content written to disk), before the system closes down. Else files are left in an 'undetermined state'. And that's a very bad thing for files to be left in.
Flushing is achieved by 'unmounting' the partitions during proper system shutdown. Don't switch your system off while it is running! You may get away with it quite often, since the Linux file system is very robust, but you may also wreak havoc upon important files. Just hit <CTRL ALT DEL> or use the proper commands (e.g. init 6) / buttons. This will shut down the system in a decent way and reboot it. And thus guarantee the integrity of your files.
So far, I've told you how it should be. Now about how it is in the real world ;-).
As you will see on the following pages, the implementation of this concept
on Linux isn't perfect. Some people would even say it's far from
Linux has always attracted individualists. And these people tend to have their own opinion about a great many things, like for instance into which directories certain files should be put into. With the arrival of different distributions, these different opinions became manifest. Some distributions put mount directories for external media into the 'root' directory, others - like Mandrake Linux - into '/mnt'. Red Hat based distributions feature the '/etc/sysconfig' sub-hierarchy for configuration files concerning input and network devices. Other distributions do not have this directory at all and put the appropriate files elsewhere or even use completely different mechanisms to do the same thing. Some distributions put KDE into '/opt/', others - like Mandrake Linux - into '/usr'
But even within a given file system hierarchy, there are inconsistencies. The graphical subsystem, XFree86, has its own directory hierarchy, for example. The hierarchy has not so much been designed as 'grown'. So there are weeds.
This isn't much of a problem as long as you compile programs yourself: you can then adapt their configure scripts or Makefiles to your system's configuration. But it's different if you install pre-compiled packages like RPMs. Often these are not adaptable from one file system hierarchy to another. What's worse: some RPMs might even create their own hierarchy. If you, say, install a KDE RPM from the SuSE Linux distribution on your ML system, the binary will be put into '/opt/kde2/bin'. And thus it won't work, because ML expects it to be in '/usr/bin'.
There are of course ways to circumvent this problem (discussed in the article on RPM), but the current situation clearly is unsatisfying. Therefore all the leading GNU/Linux distributors have joined the Linux Standard Base project, which is currently trying to create a common standard for GNU/Linux distributions. As you might imagine, this isn't easy, because changing the file system hierarchy means a lot of work for distributors. And so every distributor tries to push a standard which will allow him to keep as much of his own hierarchy as possible ...
The LSB will also encompass the proposals made by the File system Hierarchy Standard project (FHS, former FSSTND). Starting with 7.2, Mandrake Linux has taken some pains to reorganize its file system hierarchy for greater FHS and LSB compliance. These changes will be discussed on the next pages, too.
The Linux file system starts with '/', the root directory. All other directories are 'children' of this directory. The partition which the root file system resides on is mounted first during boot and the system won't boot if it doesn't find it.
In Mandrake Linux, '/' contains these sub-directories:
Some of these directories can be put onto separate partitions or systems,
e.g. for easier backups, due to network topology or security concerns. Other
directories have to be on the root partition, because they are vital
for the boot process.
'Mountable' directories are: '/home', '/mnt', '/tmp', '/usr' and '/var'. Essential for booting are: '/bin', '/boot', '/dev', '/etc', '/lib', '/proc' and '/sbin'.
'/etc' is the nerve center of your system, it contains all system related configuration files.
Some important subdirectories:
Some network configuration files in /etc
hosts bind, i.e. "check /etc/hosts first and then look for a DNS").
'/etc/resolv.conf' tells the network which name servers it should use for unknown addresses.
Some system configuration files in /etc
inithow to handle runlevels. Sets the default runlevel.
And many, many more. I suggest that you should browse this directory, it will teach you a lot about your Linux system and how you can customize it!
'/home/$USER' (aka '~/') is your playground: everything's at your command,
you can write files, delete them, install programs etc.
Your home directory contains your personal configuration files, the so-called dot files (their name is preceded by a dot). Personal configuration files are usually 'hidden', if you want to see them, you either have to turn on the appropriate option in your file manager or run 'ls' with the '-a' option. If there is a conflict between personal and system-wide configuration files, the settings in the personal file will prevail.
'/home' can get quite large (mine is about 400 MB) and can be used for storing downloads, compiling, installing and running programs, your mail, your collection of image or sound files etc.
'/var' holds 'variable' data like spool directories for mail and news, data bank data and log files.
original Unix implementations, /usr was where the home directories of the
users were placed (that is to say, /usr/someone was then the directory now
known as /home/someone ).[...] In current Unices, /usr is where user-land
programs and data (as opposed to 'system land' programs and data) hang out.
The name hasn't changed, but it's meaning has narrowed and lengthened from
"everything user related" to "user usable programs and data"."
(Lew Pitcher on /.)
The '/usr' directory contains the vast majority of files on every Linux
box. All the programs go there, their documentation, their libraries, their
header files etc.
At a first glance, the listing of this directory is really frightening. It is very easy to get lost in here.
Another large subdirectory-structure begins here, containing libraries,
executables, docs, fonts and much more concerning the X Window System.
Its inclusion here is somewhat inconsistent and so is the difference between '/usr' and '/usr/X11R6' directories. One would assume that programs that run on X only have their files in the '/usr/X11R6' hierarchy, while the others use '/usr'. Regrettably, it isn't so. KDE and GNOME put their files in the '/usr' hierarchy, whereas the window manager Window Maker uses '/usr/X11R6'.
Documentation files for X11R6 are not in '/usr/X11R6/doc', but primarily in '/usr/X11R6/lib/X11/doc' (one might not have guessed that, hum? ;-)).
This mess is due to the fact that in contrast to other operating systems, the graphical desktop isn't an integral part of the system. Linux is still primarily used on servers, where graphical systems don't make sense.
This directory contains the vast majority of binaries (executables) on your system.
In older releases, this was the central documentation directory. Current releases use '/usr/share/doc'.
Theoretically, that's another directory for configuration files. Practically, I've yet to see a reason to use it.
Once upon a time, this directory contained network games files. It's rarely used nowadays.
Used to store some compiler related files.
The directory for 'header files', needed for compiling source code.
In older releases, this directory contained the files of the info documentation system. Now they are in '/usr/share/info'.
This directory contains program libraries. Libraries are collections of frequently used program routines.
I would lie if I'd say I'd know what this directory is good for.
The original idea behind '/usr/local' was to have a separate ('local') '/usr' directory on every machine besides '/usr', which might be just mounted read-only from somewhere else. It copies the structure of '/usr'. These days, '/usr/local' is widely regarded as a good place to keep self-compiled or third-party programs in.
In older releases, this directory contained the man pages. Has been moved to '/usr/share/man'.
This directory contains programs for administering a system, meant to be run by 'root'. Like '/sbin', it's not part of a user's $PATH.
This directory contains 'shareable', architecture-independent files (docs,
icons, fonts etc).
"Note, however, that '/usr/share' is generally not intended to be shared by different operating systems or by different releases of the same operating system.
Any program or package which contains or requires data that doesn't need to be modified should store that data in '/usr/share' (or '/usr/local/share', if installed locally). It is recommended that a subdirectory be used in /usr/share for this purpose."
(From the File system Hierarchy Standard)
The 'linux' sub-directory holds the Linux kernel sources, header-files and documentation. 'RPM/' provides a substructure for building RPMs from SRPMs.
Hey, look, another directory for temporary files! ;-) It's just a link to 'var/tmp/', though.
Well, I hope this was exhaustive enough for you. It sure was for me ;-).