FHS (File Hierarchy System) on Unix-like operating systems such as Linux

The Linux file system can seem a little strange especially for those coming from an M$ Windoze background. This is my humble attempt at debunking it and perhaps making it a little easier to understand.

Several main differences…

There are some important differences between the DOS/Windows type file system and the system used by Unix-derived systens such as Linux and Macintosh OSX.

  1. Folder delimiter is a forwardslash  “/” not a backslash “\”.
  2. Disk drives do not have drive letters. Instead they are mounted from within the file hierarchy system.
  3. File and folder names are case sensitive.
  4. Files and folders are hidden by adding a preceding dot.
  5. File and folder permissions are completely different.
  6. Unixy folks often refer to “folders” as “directories”.
  7. The shorthand to access the current user’s home folder is ~/ In my case ~/ is the same as /home/garf

Basic FHS


(Note this deviates slightly from official FHS by including some Debian-based paths as well.)


/
Primary hierarchy root and root directory of the entire file system hierarchy.


/bin/
Essential command binaries that need to be available in single user mode; for all users (e.g., cat, ls, cp).


/boot/
Boot loader files (e.g., kernels, initrd). Often a separate partition.


/dev/
Essential devices (e.g., /dev/null).


/etc/
Host-specific system-wide configuration files (the name comes from et cetera).

/etc/opt/
Configuration files for /opt/.

/etc/X11/
Configuration files for the X Window System, version 11.

/etc/sgml/
Configuration files for SGML.

/etc/xml/
Configuration files for XML.


/home/
Users’ home directories – containing saved files, personal settings etc. Often a separate disk partition.

/home/garf/
Where my stuff lives. (Not actuallly part of the official FHS – obviously)


/lib/
Libraries essential for the binaries in /bin/ and /sbin/.


/media/
Mount points for removable media such as CD-ROMs (appeared in FHS version 2.3).


/mnt/
Temporarily mounted filesystems.


/opt/
Optional application software packages.


/proc/
Virtual filesystem documenting kernel and process status as text files (e.g., uptime, network).


/root/
Home directory for the root user.


/sbin/
Essential system binaries (e.g., init, route, ifup).


/srv/
Site-specific data which is served by the system.


/tmp/
Temporary files (see also /var/tmp).


/usr/
Secondary hierarchy for user data; contains the majority of (multi-)user utilities and applications.

/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/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.

/usr/local/
Tertiary hierarchy for local data, specific to this host. Typically has further subfolders, eg. bin/, lib/, share/.


/var/
Variable files, such as logs, spool files, and temporary e-mail files.

/var/cache/
(debian-based systems) ccached files.

/var/cache/apt/
*.deb files downloaded when getting or updating packages from repositories, e.g. when using “sudo apt-get install”.

/var/lock/
Lock files. Files keeping track of resources currently in use.

/var/log/
Log files. Various logs.

/var/mail/
Users’ mail-boxes.

/var/run/
Information about the running system since last boot (e.g. currently logged-in users and running daemons).

/var/spool/
Spool for tasks waiting to be processed (e.g. print queues and unread mail).

/var/spool/mail/
Deprecated location for users’ mail-boxes.

/var/tmp/
Temporary files to be preserved between reboots.

/var/www/
Web site files (not strictly part of the FHS but this is a very common location in the hierarchy).


Related Images: