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