the Linux file tree

This post takes a look at the most common directories in the Linux file tree. It also shows that on Unix everything is a file.

filesystem hierarchy standard

Many Linux distributions partially follow the Filesystem Hierarchy Standard. The FHS may help make more Unix/Linux file system trees conform better in the future. The FHS is available online at where we read: “The filesystem hierarchy standard has been designed to be used by Unix distribution developers, package developers, and system implementers. However, it is primarily intended to be a reference and is not a tutorial on how to manage a Unix filesystem or directory hierarchy.”

man hier

There are some differences in the filesystems between Linux distributions. For help about your machine, enter man hier to find information about the file system hierarchy. This manual will explain the directory structure on your computer.

the root directory /

All Linux systems have a directory structure that starts at the root directory. The root directory is represented by a forward slash, like this: /. Everything that exists on your Linux system can be found below this root directory. Let’s take a brief look at the contents of the root directory.


binary directories

Binaries are files that contain compiled source code (or machine code). Binaries can be executed on the computer. Sometimes binaries are called executables.


The /bin directory contains binaries for use by all users. According to the FHS the /bin directory should contain /bin/cat and /bin/date (among others).

In the screenshot below you see common Unix/Linux commands like cat, cp, cpio, date, dd, echo, grep, and so on.


other /bin directories

You can find a /bin subdirectory in many other directories. A user named serena could put her own programs in /home/serena/bin.

Some applications, often when installed directly from source will put themselves in /opt. A samba server installation can use /opt/samba/bin to store its binaries.


/sbin contains binaries to configure the operating system. Many of the system binaries require root privilege to perform certain tasks.

Below a screenshot containing system binaries to change the ip address, partition a disk and create an ext4 file system.



Binaries found in /bin and /sbin often use shared libraries located in /lib. Below is a screenshot of the partial contents of /lib.
paul@laika:~$ ls /lib/libc*
/lib/            /lib/        /lib/

/lib/           /lib/            /lib/

/lib/      /lib/               /lib/

/lib/        /lib/         /lib/


Typically, the Linux kernel loads kernel modules from /lib/modules/$kernel-version/.

/lib32 and /lib64

We currently are in a transition between 32-bit and 64-bit systems. Therefore, you may encounter directories named /lib32 and /lib64 which clarify the register size used during compilation time of the libraries. A 64-bit computer may have some 32-bit binaries and libraries for compatibility with legacy applications. This screenshot uses the file utility to demonstrate the difference.

root@localhost:~$ file /lib32/
/lib32/ ELF 32-bit LSB shared object, Intel 80386, \
version 1 (SYSV), for GNU/Linux 2.6.0, stripped
root@localhost:~$ file /lib64/
/lib64/ ELF 64-bit LSB shared object, AMD x86-64, \
version 1 (SYSV), stripped

The ELF (Executable and Linkable Format) is used in almost every Unix-like operating system since System V.


The purpose of /opt is to store optional software. In many cases this is software from outside the distribution repository. You may find an empty /opt directory on many systems.

A large package can install all its files in /bin, /lib, /etc subdirectories within /opt/ $packagename/. If for example the package is called wp, then it installs in /opt/wp, putting binaries in /opt/wp/bin and manpages in /opt/wp/man.

configuration directories


The /boot directory contains all files needed to boot the computer. These files don’t change very often. On Linux systems you typically find the /boot/grub directory here. /boot/grub contains /boot/grub/grub.cfg (older systems may still have /boot/grub/grub.conf) which defines the boot menu that is displayed before the kernel starts.


All of the machine-specific configuration files should be located in /etc. Historically /etc stood for etcetera, today people often use the Editable Text Configuration backronym. Many times the name of a configuration files is the same as the application, daemon, or
protocol with .conf added as the extension.


There is much more to be found in /etc.


A lot of Unix/Linux distributions have an /etc/init.d directory that contains scripts to start and stop daemons. This directory could disappear as Linux migrates to systems that replace the old init way of starting all daemons.


The graphical display (aka X Window System or just X) is driven by software from the foundation. The configuration file for your graphical display is /etc/X11/xorg.conf.


The skeleton directory /etc/skel is copied to the home directory of a newly created user. It usually contains hidden files like a .bashrc script.


This directory, which is not mentioned in the FHS, contains a lot of Red Hat Enterprise Linux configuration files. The screenshot
below is the /etc/sysconfig directory from RHELv4u4 with everything installed.


The file /etc/sysconfig/firstboot tells the Red Hat Setup Agent not to run at boot time. If you want to run the Red Hat Setup Agent at the next reboot, then simply remove this file, and run chkconfig –level 5 firstboot on. The Red Hat Setup Agent allows you to install the latest updates, create a user account, join the Red Hat Network and more. It will then create the /etc/sysconfig/firstboot file again.

root@localhost:~$ cat /etc/sysconfig/firstboot

The /etc/sysconfig/harddisks file contains some parameters to tune the hard disks. The file explains itself.

You can see hardware detected by kudzu in /etc/sysconfig/hwconf. Kudzu is software from Red Hat for automatic discovery and configuration of hardware.

The keyboard type and keymap table are set in the /etc/sysconfig/keyboard file. For more console keyboard information, check the manual pages of keymaps(5), dumpkeys(1), loadkeys(1) and the directory /lib/kbd/keymaps/.

root@localhost:/etc/sysconfig# cat keyboard


For any query or issue, feel free to discuss on