Thursday, June 13

Linux Directory Structure Explained

Leave a Comment
Linux and Unix file system is defined by 'Filesystem Hierarchy Standard(FHS)', If you are a complete windows user and are new comer to linux based OS like Ubuntu or Fedora then the file system structure of linux may look alien with all those cryptic named folders.

In this post we will go in to great detail explaining the file system structure of linux. To this particular post we will be using Ubuntu as the base and even if you are using other linux based OS, the file system will mostly be similar to Ubuntu, So no worries.

Note: Ubuntu may also contain files and folders which are not yet included in FHS.
          EX: /cdrom

Linux Filesystem Hierarchy Standard


This is the root directory of your linux box, typically every thing goes from here. This is something like C drive of your windows machine.


/bin directory contains essential user binaries which are required when the system is mounted in single-user-mode. Don't get this confused with /usr/bin where user specific applications like compiz or firefox are stored.


The name says it, Here the static files like GRUB and linux kernels required to boot the system are stored.


In simple this is the temporary location for CD-ROMs inserted in to your system. As mentioned above this is not part of FHS but you can see it in Ubuntu and other linux based OS's.


The /dev directory contains all the device files. In linux world, everything is seen as files and folders including your hardware. For example you can find your hard drive under '/dev/sda' and cd-rom under '/dev/cdrom', etc.
This drive not only contains physical devices but also contains virtual pseudo-devices.


/etc contains system wide configuration files which can be edited using simple text editor. It does not contain user specific configuration files as they are situated under each user's home directory.


The /home directory contains the home folder of each user. Each user has write permission to his/her folder only and must obtain elevated permission to modify system files.
Each users home folder contains user-specific-config files and data files.


The /lib directory contains library files which are used by the binaries in /bin and /sbin directories.


The /media directory contains sub folders of mounted removable media. For example, if you insert some usb stick or cd-rom then you can see a folder mounted automatically inside /media directory.


Simply speaking this is the temporary mounting point for system administrators to mount other file systems like windows.


This /opt directory is used by propitiatory software packages which doesn't follow FHS.


This is the directory which contains files representing system and process information and basically it is very similar to /dev directory.


To be simple, this is the home directory of *root* user. It contains data and config files of root user. Unlike normal users whose home folders are situated in /home/user, Root users have their home folder directly under /root directory.


This /run directory contains application state files which provided application to store their transient files required like processes ID and sockets.


This /sbin directory is actually similar to /bin directory but contains system administration binaries which are generally intended to run by the root user.


This directory has nothing to do with Ubuntu as Ubuntu doesn't use SElinux. Actually /selinux is used to store security related files which is also similar to /proc directory. SElinux is used by other linux distros like Fedora and Red Hat.


/srv is defined as the directory containing the service data.


The /tmp directory contains all the temporary files of running application which are deleted as soon as the application is closed or after some interval.


The /usr directory contains user binaries and other read only data of specific user and not the system specific binaries or data.
There are other sub folders in /usr directory like /usr/local where locally compiled applications are installed, /usr/bin where non-essential applications are installed, /usr/sbin where non-specific system administration binaries stored.


To be simple this is a writable version of /usr(which is read-only) folder which contains variable data files like logs files.

Here is the PDF version of this article which you can download and use


Post a Comment