The File Store & Directories

Introduction

Because Linux is an open source system anyone can download it, modify it and release it to others, while this freedom is fantastic, it also introduces a potential problem - namely fragmentation. Fragmentation is where several versions of a piece of software exist and are developed separately to the point where they become incompatible. The way to prevent fragmentation is to introduce standards. This means that anything which is calling itself Linux should follow these standards, and in so doing it makes everyone's life easier. One of these standards is the "Filesystem Hierarchy Standard"(FHS). The full definition of the FHS can be found here

http://www.pathname.com/fhs/pub/fhs-2.3.html
However as with most standard specifications it's not a light skim over the subject.

The directory tree

The layout of a file system can be thought of as a tree, branching from the root out to its various subdirectories and the FHS defines the shape of this tree. It should be noted that everything on a Linux system is represented on this tree, files, directories, printers, keyboards and even network streams. Regardless of how many physical disks the system has, there is only one root directory which is known as "/", you can list its contents with the following command

ls /

This will return a listing something like the following:

bin etc lib opt sbin usr
boot home media proc srv var
dev initrd.img mnt root tmp vmlinuz

You may have other files and directories there also, but the list above should be there.

What goes Where

So, we have a basic layout but what goes in each directory? It should first be noted that before the days of tab completion in the shell we users had to type out the whole name of a directory and no one wants to type out

/system_binaries/file_system_check if they don't have to as it's possible that they would make an error in the name and have to start again and also it could lead to RSI. So the names of directories and commands in Linux have been shortened to make life easier (once you get to know what they mean)

bin: This is the binaries directory where executable files are kept.

boot: This contains all the files needed to start the Linux system

dev: This contains the device files, these are special files which send and receive data from hardware on your system
etc: This is where all the system-wide configuration files go, programs can add their own directories to structure their configuration files if they have complex configurations for example the Thunderbird application has the following structure:


/etc/thunderbird/
|-- pref/
| `-- thunderbird.js
`-- profile/
|-- localstore.rdf
|-- mimeTypes.rdf
|-- prefs.js
`-- US/
|-- localstore.rdf
`-- mimeTypes.rdf


home: This contains the personal directories for all users. These folders should contain the users' personal data and also contain any personal settings which over-ride the system wide settings in /etc. These personal settings are stored in hidden files (a file beginning with a dot is not displayed in
ordinary file listings)
lib: Library files supply common functions to the programs you use, they are stored under /lib, /usr/lib and /usr/local/lib.
media: A mount point for removable media such as CDs DVDs etc...
mnt: A mount point for temporarily mounted filesystems
opt: Abreviation for optional, all 3rd party software goes here (eg. commercial software installed onto a Linux system)
proc: This is a special filesystem in its own right, it maps the currently running processes including the kernel and can be used to tweak running programs, use with extreme care.
root: The home directory of the root user
sbin: System administration binaries, these are programs for use in system administration rather than common user commands.
srv: This is for data associated with services, eg /srv/www/index.html would be the home page of the web server on the system.
tmp: Location of temporary files and directories, usable by all programs but there is no guarantee that files written here will remain present the next time the program is run.
usr: This is a full hierarchy of directories in its own right, it is possible to share this amoungst several running systems over the network. it is a read only tree (though a local directory can be used to point to provide site specific libraries and programs.)
var: Files of varying length are put here, for example log files, spool files (a spool fie is one where actions are queued for software or hardware eg. a printer spool or a mail spool).