\ Mage Blog

Directory Structure

In Linux, all files and directories appear under the root directory /, even if they are stored on different physical or virtual devices.


Directory Description
/
Primary hierarchy root and root directory of the entire file system hierarchy. The root directory is the first or top-most directory in a hierarchy.
/bin
Essential command binaries that need to be available in single user mode; for all users, example: pwd, ping, cat, ls, cp. vi
/dev
dev is the location of special or device files. Examples:
ttyXX - terminal
/dev/cdrom - cd rom
/dev/lpX - printer
/dev/null - null device

The majority of devices are either block or character devices; however other types of devices exist and can be created. In general, 'block devices' are devices that store or hold data, 'character devices' can be thought of as devices that transmit or transfer data. For example, diskette drives, hard drives and CD-ROM drives are all block devices while serial ports, mice and parallel printer ports are all character devices.
/home
This directory contians users' home directories, containing saved files, personal settings, etc. Each user is assigned a specific directory that is accessible only to them and the system administrator. These are the user home directories, which can be found under '/home/$USER' (~/).
/mnt
Directory for temporarily mounted filesystems. The /mnt directory and its subdirectories are intended for use as the temporary mount points for mounting storage devices, such as CDROMs, floppy disks and USB (universal serial bus) key drives.
/proc
Virtual filesystem providing process and kernel information as files. In Linux, corresponds to a procfs mount.
/run
Run-time variable data: Information about the running system since last boot, e.g., currently logged-in users and running daemons.
/srv
Site-specific data which are served by the system. Sometimes used as webroot.
/tmp
Temporary files to be preserved between reboots.
/etc
Host-specific system-wide configuration files

The etcetera directory, as this directory historically held everything that did not belong elsewhere (however, the FHS restricts /etc to static configuration files and may not contain binaries). Since the publication of early documentation, the directory name has been re-explained in various ways. Recent interpretations include ackronyms such as "Editable Text Configuration" or "Extended Tool Chest".

/etc/opt
Configuration files for add-on packages that are stored in /opt/.
/etc/sgml
Configuration files, such as catalogs, for software that processes SGML.
/etc/X11
Configuration files for the X Window System, version 11.
/etc/xml
Configuration files, such as catalogs, for software that processes XML.
/lib
Libraries essential for the binaries in /bin/ and /sbin/.
/lib<qual>
Alternate format essential libraries. Such directories are optional, but if they exist, they have some requirements.
/media
Location for mount points for removable media such as CD-ROMs.
/proc
Virtual filesystem providing process and kernel information as files. In Linux, corresponds to a procfs mount.
/root
Home directory for the root user.
/run
Run-time variable data: Information about the running system since last boot, e.g., currently logged-in users and running daemons.
/sbin
Essential system binaries, e.g., fsck, init, route, ifconfig.
/srv
Site-specific data which are served by the system.
/tmp
Temporary files (see also /var/tmp). Often not preserved between system reboots, and may be severely size restricted.
/usr
Secondary hierarchy for read-only user data; contains the majority of (multi-)user utilities and applications. Stands for Unix System Resources, Not "User". /usr usually contains by far the largest share of data on a system. Hence, this is one of the most important directories in the system as it contains all the user binaries, their documentation, libraries, header files, etc.... X and its supporting libraries can be found here. User programs like telnet, ftp, etc.... are also placed here.
/usr/bin
Non-essential command binaries (not needed in single user mode; for all users.
/usr/include
Standard include files.
/usr/lib
Libraries for the binaries in /usr/bin/ and /usr/sbin/.
/usr/lib<qual>
Alternate format libraries (optional).
/usr/local
Tertiary hierarchy for local data, specific to this host. Typically has further subdirectories, e.g., bin/, lib/, share/.
/usr/sbin
Non-essential system binaries, e.g., daemons for various network-services.
/usr/share
Architecture-independent (shared) data.
/usr/src
Source code, e.g., the kernel source code with its header files.
/usr/X11R6
X Window System, Version 11, Release 6 (up to FHS-2.3, optional).
/var
Variable files—files whose content is expected to continually change during normal operation of the system—such as logs, mail and printer spool files, and temporary e-mail files. If /var cannot be made a separate partition, it is often preferable to move /var out of the root partition and into the /usr partition. Web pages are generally stored under /var/www. Log files are found under /var/log.
/var/cache
Application cache data. Such data are locally generated as a result of time-consuming I/O or calculation. The application must be able to regenerate or restore the data. The cached files can be deleted without loss of data.
/var/lib
State information. Persistent data modified by programs as they run, e.g., databases, packaging system metadata, etc.
/var/lock
Lock files. Files keeping track of resources currently in use.
/var/log
Log files. Various logs.
/var/mail
Users' mailboxes.
/var/opt
Variable data from add-on packages that are stored in /opt/.
/var/www
Default document root location for Red Hat versions of apache
/var/run
Run-time variable data. This directory contains system information data describing the system since it was booted.

In FHS 3.0, /var/run is replaced by /run; a system should either continue to provide a /var/run directory, or provide a symbolic link from /var/run to /run, for backwards compatibility.

/var/spool
Spool for tasks waiting to be processed, e.g., print queues and outgoing mail queue.
/var/spool/mail
Deprecated location for users' mailboxes.
/var/tmp
Temporary files to be preserved between reboots.
/boot
Boot loader files, e.g., kernels, initrd. Files needed to boot system.
/etc
Host-specific system-wide configuration files. Generally contains static configuration files and not binaries.
/lib
Libraries essential for the binaries in /bin/ and /sbin/.
/media
Mount points for removable media such as CD-ROMs
/opt
Optional application software packages.
/sbin
Essential system binaries, e.g., fsck, init, route.
/sys
virtual filesystem
/usr
Secondary hierarchy for read-only user data; contains the majority of (multi-)user utilities and applications.
/usr/bin
Non-essential command binaries used in the very early boot stage or ones that you need to have available in booting single-user mode. Example: cat, ls, etc.
/usr/include
Standard include files.
/usr/lib
Program libraries for the binaries in /usr/bin/ and /usr/sbin/.
/usr/lib<qual>
Alternate format libraries (optional).
/usr/local
Tertiary hierarchy for local data, specific to this host. Typically has further subdirectories, e.g., bin/, lib/, share/.[7]
/usr/sbin
Non-essential system binaries, e.g., daemons for various network-services. Examples: postfix, httpd, rotatelogs, vsftpd
/usr/share
Architecture-independent (shared) data.
/usr/src
Source code, e.g., the kernel source code with its header files.
/usr/X11R6
X Window System, Version 11, Release 6 (up to FHS-2.3, optional).