File System Hierarchy

The Linux File System Hierarchy

It is without a doubt, if you come from from windows, you notice the file
system is extremely different. There are no capital letters specifying where you
are on the system like “C:\” , instead when you open up a shell, you are most
likely in what it considers your home directory at “/home/USERNAME/” also known
as “~” in your shell. Today we will be discussing the internals of the file
system hierarchy.
At the very top, the root directory is specified as “/” . On top of that, you
have multiple directories which names are short and to the point:

1. /bin: Essential command binaries
2. /boot: Static files of the boot loader
3. /dev: Device files
4. /etc: Host-specific system configuration
5. /lib: Essential shared libraries and kernel modules
6. /media: Mount point for removable media
7. /mnt Mount point for mounting a filesystem temporarily
8. /opt: Add-on application software packages
9. /run: Data relevant to running processess
10. /sbin: Essential system binaries
11. /srv: Data for services provided by this system
12. /tmp: Temporary files
13. /usr: Secondary hierarchy
14. /var: Variable data
15. /home: User home directories (optional)
16. /lib Alternate format essential shared libraries(optional)
17. /root Home directory for the root user (optional)

These are all defined withing the file system hierarchy standard that the
Linux Base Standard provides.

1. /bin
/bin contains commands that may be used by both the system administrator and
by users, but which are required when no other file systems are mounted (e.g. in
single user mode). It may also contain commands which are used indirectly by
scripts.The following commands, or symbolic links to commands, are required in

/bin :
cat , chgrp , chmod , chown , cp , date , dd , df , dmesg , echo , false ,
hostname , kill , ln , login , ls , mkdir , mknod , more , mount , mv , ps ,
pwd , rm , rmdir , sed , sh , stty , su , sync , true , umount , uname

The standard also defines these as optional in /bin:
csh , ed , tar , cpio , gzip , gunzip , zcat , netstat , ping

2. /boot
This directory contains everything required for the boot process except
configuration files not needed at boot time and the map installer. Thus /boot
stores data that is used before the kernel begins executing user-mode programs.
This may include saved master boot sectors and sector map files.Programs
necessary to arrange for the bootloader to be able to boot a file must be
placed in /sbin.Configuration files for boot loaders that are not required at
boot time must be placed in /etc. The operating system kernel must be located in
either / or /boot. Certain architectures may have other requirements for /boot
related to limitations or expectations specific to that architecture. These
requirements are not enumerated here; distributions are allowed to add
requirements as needed to enable system startup on these architectures.

3. /dev
The /dev directory is the location of special or device files.If it is
possible that devices in /dev will need to be manually created, /dev must
contain a command named MAKEDEV, which can create devices as needed. It may also
contain a MAKEDEV.local for any local devices.If required, MAKEDEV must have
provisions for creating any device that may be found on the system, not just
those that a particular distribution installs.

4. /etc
The /etc hierarchy contains configuration files. A “configuration file” is a
local file used to control the operation of a program; it must be static and
cannot be an executable binary. /etc may contain executable scripts, such as
the command scripts commonly called by init to start and shut down the system
and start daemon processes. “Executable binary” in this context refers to direct
machine code or pseudocode not in a human-readable format, such as native ELF
executables.It is recommended that files be stored in sub-directories of /etc
rather than directly in /etc

5. /lib
The /lib directory contains those shared library images needed to boot the
system and run the commandsin the root filesystem, ie. by binaries in /bin and
/sbin. At least one of each of the following filename patterns are required
(they may be files, or symbolic links): libc.so.* or ld*

6. /media
This directory contains subdirectories which are used as mount points for
removable media such as floppydisks, cdroms and zip disks.The following
directories, or symbolic links to directories, must be in /media, if the
corresponding subsystem is installed: floppy, cdrom, cdrecorder, zip

7. /mnt
This directory is provided so that the system administrator may temporarily
mount a filesystem as needed.The content of this directory is a local issue and
should not affect the manner in which any program is run.This directory must not
be used by installation programs: a suitable temporary directory not in use by
the system must be used instead.

8. /opt
/opt is reserved for the installation of add-on application software packages.
A package to be installed in /opt must locate its static files in a separate
/opt/ or /opt/ directory tree, where is a name
that describes the software package and is the provider’s LANANA
registered name. LANANA Stands for Linux Assigned Names And Numbers Authority
and more information can be found at : http://www.lanana.org/ . The directories
/opt/bin, /opt/doc, /opt/include, /opt/info, /opt/lib, and /opt/man are reserved
for local system administrator use. Packages may provide “front-end”
files intended to be placed in (by linking or copying) these reserved
directories by the local system administrator, but must function normally in the
absence of these reserved directories.Programs to be invoked by users must
be located in the directory /opt//bin or under the /opt/
hierarchy. If the package includes UNIX manual pages, they must be located in
/opt//share/man or under the /opt/ hierarchy, and the same
substructure as /usr/share/man must be used.Package files that are variable
(change in normal operation) must be installed in /var/opt. See the section
on /var/opt for more information.Host-specific configuration files must be
installed in /etc/opt. See the section on /etc for more information. No other
package files may exist outside the /opt, /var/opt, and /etc/opt hierarchies
except for those package files that must reside in specific locations within the
file system tree in order to function properly. For example, device lock files
must be placed in /var/lock and devices must be located in /dev. Distributions
may install and otherwise manage software in /opt under an appropriately
registered sub-directory.

I touched briefly on a number of directories within the root directory in this
tutorial . To learn more about the full filesystem hierarchy, you can go to :

Click to access fhs-3.0.pdf

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s