Linux/Unix Directories

by Ed Sawicki
Accelerated Learning Center
Tailored Computers

December 18, 2003

People who are new to Linux or Unix frequently ask why the Linux/Unix directory hierarchy is so complicated and why there are so many directories that programs are stored in. The need for so many directories seems elusive to someone coming from, say, the Windows world.

There are many reasons why there are so many directories. Here are a few reasons with simplistic explanations:

  1. Users - Ordinary users login and do work. Superusers login as root only when the additional power of the root account is required to reconfigure the system, manage user accounts, etc. There are directories that contain programs that ordinary uses have access to (/bin, /usr/bin, and /usr/local/bin) and other directories that contain programs that only the superusers have access to (/sbin, /usr/sbin, and /usr/local/sbin). The separation of user and administrator programs helps improve security.
  2. Shares - Some directories are always located on the local computer (/bin and /sbin) while others (/usr/bin and /usr/sbin) may be located on remote computers. Note that diskless computers that boot from a network server are a special case. All directories will be on the remote computer.
  3. Security - Directories that appear to have the same purpose as other directories may exist because the system admin applies different permissions, attributes, or mount options to the directories or the files within them to achieve greater security and privacy.
  4. Distributions - Linux distributions include tools to keep the system's software updated. Sometimes we may install our own software without using these tools. To prevent confusion about whether programs were installed by ourselves or by the tools, we use different directories for software not installed by the tools (/usr/local/bin and /usr/local/sbin, for example).
  5. Loopback file systems - Linux supports extremely useful things called loopback file systems that don't exist in the Windows world. These loopback file systems offer more functionality than you find in the standard file system, such as encryption, compression, and non-persistance. These loopback file systems require their own directory as a mount point.
  6. Sealed systems - Sealed systems are a new concept that offer the system builder both mutable and immutable storage. The idea is to achieve high levels of security by placing as many files as possible in immutable storage so they can't be altered by an attack. Additional directories may be required for immutable storage.
  7. Virtual machines - Linux has a virtual machine capability, called User Mode Linux (UML) that allows a Linux operating system to run within another Linux operating system. There are numerous practical applications for UMLs. These operating systems, which are otherwise completely separate from one another, may share a common directory structure. An admin may choose to create another directory for this common directory tree.

There is a document and standard called the Filesystem Hierarchy Standard (FHS) at http://www.pathname.com/fhs/ that goes into more detail about the Linux/Unix directory structure. However, the FHS documents the traditional Unix directory structure and may be viewed by some as behind the times in terms of cutting-edge technologies like loopback file systems, sealed systems, virtual machines, etc.

My company, the Accelerated Learning Center, offers a course, called Linux Advanced, that covers the advanced concepts and techniques described briefly above.

Back