Stugon Explains: Linux Directory Structure

linux

Six years back when I first used Linux I’m like ‘I don’t like Linux’, well this is because I just can’t stand all those alien named folders & I can’t see my C, D, E, F drives, I can’t find add remove programs, no command prompt,  etc. But the thing is, Everything takes time to adopt so I just sat before my windows machine surfed through the internet, learned a bit and really started to love Linux based OS Ubuntu & here I am. So, this article is for beginners who are pretty new and are willing to know more about Linux Directory Structure.

Linux and Unix file system is defined by ‘Filesystem Hierarchy Standard(FHS)’, If you are a complete windows user and are a newcomer to Linux based OS like Ubuntu or Fedora then the Linux directory structure may look alien with all those cryptic named folders.

In this article we will go into great detail explaining the file system structure of Linux. For this particular post we will be using Ubuntu as the base and even if you are using another Linux based OS, the file system will mostly be similar to Ubuntu, So no worries.

Linux-Filesystem-Hierarchy-Standared

/
This is the root directory of your Linux box, typically everything 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 into your system.

/dev
The /dev directory contains all the device files. In the 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
/Etch contains system wide configuration files which can be edited using a 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 in /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 provide applications to store their transient files required, like process ID’s 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 service data.

/tmp
The /tmp directory contains all the temporary files of running applications 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 /us (which is read-only) folder which contains variable data files like log files.

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

Download this as PDF file