Learn Linux Directory Structure in Detail

The Linux file directory structure begins at root (/) which looks like a tree. Basically, those are folders on the hard drive where Linux is installed and organized.

You can use ls command to list the file directory structure. Use mkdir command to create directories, mv command to rename directories and cd command to change directory.

Let's learn the Linux directory structure in detail.

Linux directory structure cheat sheet

Linux directory structure and compared with windows

If you are coming from Microsoft Windows users, then you will found that Linux directory structure is not different from Microsoft Windows. Here’s the comparison between them.

NoLinux DirectoryFunctionComparison with Microsoft Windows 7
1/The top directory of LinuxC:\
2/binStore binary files which related to the system such as mount, ls, rm, etcC:\Windows
3/bootStore files related to boot processC:\Windows
4/devStore information about all devices which connected to your LinuxC:\Windows
5/etcStore configuration files about Linux and its applicationC:\Windows
6/homeUser directoryMy Documents
7/libStore library filesC:\Windows\system
8/lost+foundlost+found is the directory in which fsck (filesystem check) will put files it restores from orphaned blocksFound.000
9/mediaUsually used as a moint point for external media such as CD/DVD ROMD: or E: drives
10/mntUsed as a mount point directory, but it more likely a place that “temporarily mounted” device such as network shares.A mapped drive such as X: , Y:, Z:
11/optStore files which not handled by package managerNone
12/procA virtual filesystem which used to provide information about the systemC:\Windows\system or C:\Windows\System32
13/rootAs root home directoryMy Documents for Administrator
14/sbinStore a binary files which usually can be run by superuser onlyC:\Windows
15/selinuxStore information about Security Enhanced. Some Linux distributionmay not have this directoryNone
16/srvStore data services which used by systemNone
17/sysStore information related about your Linux systemC:\Windows\system or C:\Windows\System32
18/tmpUsed as a temporary folder for applicationsC:\Windows\Temp
19/usrStore user utilities and applicationsC:\Program Files or C:\ProgramData
20/varStore variable data filesNone

Below is a screenshot of CentOS 6.4 directory structure look like.

Linux directory structure CentOS 6.4

But again, on Debian based Linux, such as Ubuntu, the structure may a little bit different. Below is a screenshot of directory structure on Ubuntu 13.04

Ubuntu 13.04 directory structure

On Ubuntu 13.04, we have /cdrom directory while on CentOS 6.4 we don’t have it. But generally, the structure is identical.

Then we see that on Ubuntu 13.04 keeps a symbolic link of initrd.img and vmlinuz files below the / partition while on CentOS 6.4 we don’t find it.

More information about the structure

When you access /usr directory, we will found that /usr directories partly replicate root ( / ) directory. The content of /usr directory of CentOS 6.4 is like this :

  • /usr/bin is a directory that store binary files which related to common usage such as clear, gcc, bunzip2
  • /usr/etc is a directory that store application configuration files
  • /usr/games is a directory that contain of games applications
  • /usr/include is a directory that store header files
  • /usr/lib is a directory that store library files
  • /usr/libexec is a directory that store library files in binary form
  • /usr/local is a directory that usually used as a placed for additional user applications
  • /usr/sbin is a directory that store user application binary files which require superuser privileges
  • /usr/share is a directory that usually keeps documentation files of application that installed in your Linux
  • /usr/src is a directory which keeps the source files of the user application
  • /usr/tmp is a directory that used as a temporary folder for applications. This folder may point /var/tmp directory

If you dig deeper to /usr/local, then you will found an identical /usr replicate there.

/usr vs /usr/local

The tmp directory actually is a symbolic link / shortcut to /var/tmp directory.

The above screenshot was captured from CentOS 6.4. On Ubuntu, we found almost identical directory structure inside /usr and /usr local.

/usr vs /usr/local on Ubuntu

Conclusion

Linux may have a lot of distributions. But with a standardized directory structure, it will make it easier for us to understand what’s the function of each directory. If you are a Linux enthusiast who likes to try various Linux distributions, you will not find any trouble in figuring out the usage of each directory. For a Linux Administrator, it will shorten the learning curve for each Linux distributions.

Pungki Arianto 11:11 am

Comments

Your email address will not be published. Required fields are marked *

1 Comment