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

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

/boot

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

/cdrom

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.

/dev

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

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

/home

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.

/lib

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

/media

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.

/mnt

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

/opt

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

/proc

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

/root

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.

/run

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

/sbin

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

/selinux

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

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

/tmp

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.

/usr

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.

/var

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

0 comments:

Post a Comment