Learn Linux Directory Structure in a Shiny Sketch

April 23, 2014 | By
| 1 Reply More

Linux is an operating system which popular in server world. But now there are a lot of Linux distributions which also expand to desktop world. As the Linux usage grows, now Linux has Graphical User Interface (GUI) which make easier to used.

But the power of Linux stays in the background. The console. When there are something that can’t be done via GUI, you better try to use console mode. Before doing that, it’s better for us to know about Linux directory structure.

linux cheat sheet

The file structure

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

No Linux Directory Function Comparison with Microsoft Windows 7
1 / The top directory of Linux C:\
2 /bin Store binary files which related to the system such as mount, ls, rm, etc C:\Windows
3 /boot Store files related to boot process C:\Windows
4 /dev Store information about all devices which connected to your Linux C:\Windows
5 /etc Store configuration files about Linux and its application C:\Windows
6 /home User directory My Documents
7 /lib Store library files C:\Windows\system
8 /lost+found lost+found is the directory in which fsck (filesystem check) will put files it restores from orphaned blocks Found.000
9 /media Usually used as a moint point for external media such as CD/DVD ROM D: or E: drives
10 /mnt Used 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 /opt Store files which not handled by package manager None
12 /proc A virtual filesystem which used to provide information about the system C:\Windows\system or C:\Windows\System32
13 /root As root home directory My Documents for Administrator
14 /sbin Store a binary files which usually can be run by superuser only C:\Windows
15 /selinux Store information about Security Enhanced. Some Linux distributionmay not have this directory None
16 /srv Store data services which used by system None
17 /sys Store information related about your Linux system C:\Windows\system or C:\Windows\System32
18 /tmp Used as a temporary folder for applications C:\Windows\Temp
19 /usr Store user utilities and applications C:\Program Files or C:\ProgramData
20 /var Store variable data files None

 

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 13.04, 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 standardized directory structure, it will make easier for us to understand what’s the function of each directories. 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 directories. For a Linux Administrator, it will shorten the learning curve for each Linux distributions.

Filed Under : HOWTOS, LINUX HOWTO

Free Linux Ebook to Download

Comments (1)

Trackback URL | Comments RSS Feed

  1. MrDerby says:

    Awesome! Thanks for the explanation. Very much interested to learn as much as possible!

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.