Linux Directory Structure Overview

One of the most noticeable differences between Linux and Windows is the directory structure. Not only is the format different, but the logic of where to find things is different.

Introduction

In Windows, you use this format to access a directory

D:\Folder\subfolder\file.txt

In Linux, this is the basic format

/Folder/subfolder/file.txt

You’ll notice that the slashes are forward slashes in Linux versus backslashes in Windows. Also, there is no drive name (C:, D:, etc.) in Linux. At boot, the ‘root partition’ is mounted at /. All files, folders, devices and drives are mounted under /. Though it is not apparent from this example, it is important to note that files and folders in Linux are case sensitive.

/Folder/subfolder/file.txt is not the same as /folder/subfolder/file.txt.

Linux Directory Structure Overview

The Directory Structure in Unix & Linux are a unified Directory Structure where in all the directories are unified under the “/” Root file system. Irrespective of where the File System is physically mounted all the directories are arranged hierarchically under the Root file system.

The Linux Directory Structure follows the “Filesystem Hierarchy Structure (FHS)” maintained by the Free Standards Group although most of the distributions sometimes tend to deviate from the standards.

Lets have a quick stroll across the different directories under the Linux Filesystem Hierarchy

“/” Root

The Directory Structure starts with the Root file system “/” and is indeed the root directory for the whole structure.The partition where / (the root directory) will be located on a UNIX or UNIX-compatible system.

/boot

The /boot directory contains the Boot loader files including Grub or Lilo, the Kernel, initrd and system.map config files

/sys

This contains the Kernel, Firmware and system related files.

/sbin

Contains the essential System Binaries and System Administration tools essential for the system operation and performance

/bin

Contains the essential binaries for users and those utilities that are required in single user mode. Examples, include cat, ls, cp etc.

/lib

Contains the library files for all the binaries held in the /sbin & /bin directories

/dev

The /dev directory contains the essential system files and drivers.

/etc

The /etc/directory contain essential System configuration files including /etc/hosts, /etc/resolv.conf, nsswitch.conf, defaults and network configuration files. These are mostly host specific system and application configuration files.

/home

All the user home directories are held under this directory with the exception of the root home directory which is kept under /root directory. This directory holds users files, personal settings like .profile etc.

/media

A generic mount point for removable media like CD-ROM, USB, Floppies etc

/mnt

A generic mount point for temporary file systems. This comes handy particulary when troubleshooting from CDROM etc wherein you might have to mount the Root file system and edit configurations.

/opt

A rarely used directory in Linux for Optional Software Packages. This is extensively used in UNIX OS like Sun Solaris where the software packages are installed

/usr

A sub hierarchy to the root file system which is a User data directory. Contains user specific utilities and applications. You will again see a lot of important but not critical file systems are mounted. Here you would again find a bin, sbin & lib directory which contains non-critical user and system binaries and related libraries and a share directory. Also found here are the include directory with include files

/usr/sbin

Contains Non-essential Non-critical system binaries and network utilities

/usr/bin

Contains Non-Essential Non-critical command binaries for users.

/usr/lib

Library files for the binaries in /usr/bin & /usr/sbin directory.

/usr/share

A platform-independent shared data directory

/usr/local

A sub hierarchy under the /usr directory which has Local System specific data including user and system binaries and their libraries

/var

The /var directory is mostly mounted as a separate filesystem under the root where in all the variable content like logs, spool files for printers, crontab,at jobs, mail, running process, lock files etc. Care has to be taken in planning this file system and maintenance as this can fill up pretty quickly and when the FileSystem is full can cause system and application operational issues.

/tmp

A temporary file system which hold temporary files which are cleared at system reboot. There is also a /var/tmp directory which holds temporary files too. the only difference between the two is that /var/tmp directory holds files that are protected at system reboot. In other words, /var/tmp files are not flushed upon a reboot.

Then you have the virtual (psuedo) file system /proc which resides in the memory and is mounted under the Root holding kernel and process stats in text file formats.

Linux Directory Structure in Visual View

Note:-

This structure could vary from distro to distro and this is a very generic linux directory structure.The directory structure in Linux can be confusing for new users of Linux. Most distributions have the same general structure of the base directory system.

Sponsored Link

26 thoughts on “Linux Directory Structure Overview

  1. The wording of the this piece is not good — extensive editing is in order.

    In particular, the descriptions of /dev and /sys are downright misleading. /dev contains device nodes, not device drivers (which may be linked into the kernel image or reside in separate files under /lib/modules). /sys contains machine-readable textual descriptions or kernel objects, such as modules, devices, buses etc.

  2. GNU/Linux is not case sensitive; some filesystems it supports are. You can install GNU/Linux on a FAT32 partition, and it won’t have any case sensitivity.

  3. I agree the descriptions of dev and sys are atrocious; it’s a nice newbie explanation tho (nice diagram too;) Yes it should be corrected.

    “Also found here are the include directory with include files” er whut?
    “A temporary file system which hold temporary files” hmm.

  4. Hi guys,
    I want create partions for each director.I know that 100Mb more than enough to /boot directory. Anyone has idea about how much space distribute for each directory in the file hierarchy.

  5. Awesome
    that is really helpfull for users , who are working on linux
    but don’t know basics of linux

  6. Hi all,

    I’m new comer in linux
    It useful my further knowledge……

    Thanx to all
    pasindu 🙂

  7. any chance the directories could be called something meaningful like binaries or programs, settings, etc? Or does the kernel have a limited vocabulary?

  8. Can you check for the ssh daemon, if not running kindly install ssh and check it should be working.

    I guess your problem is sorted.

    Regards
    Selvam Porko

  9. hi
    in the /usr there is another subfolder called etc and include and src are there
    and again in include there is sys folder is present
    u had not specified that sub folders
    please check and correct that
    b ye

  10. I agree with one other poster about the directory naming in linux. Whoever thought of that directory naming convention should be punched in the nuts hard and often!

    I think this was a decent primer for us new people. Something like this really needs to be done in much more depth though, but it’s good nonetheless.

    Ever notice how the “beginning linux” book never cover filename and directory conventions and structure? Drives me nuts. They all pretty much just dive in without that. I had to search a lot of resource3s to find out that executable files weren’t designated by extension, but rather an attribute flag @_@

    Can’t wait to get a LAMP system setup to host a site from home =P

  11. In my opinion this file structure is seriously messed up because of the lack of a common rigid standard and developers/distros choose to put their binaries and configuration files all over the place. I use Ubuntu on my main PC for over 4 years and I use FreeBSD and Debian/Ubuntu servers in production. Every time I need a specific config change I need to search for the binaries and configuration files. Compiling and installing drivers from the source is my worst nightmare. Linux file structure definitely needs a major rework.

  12. Thanks for the primer, flaming excepted. Concur with commenter annoyance about not getting an introduction to directory system when installing Linux. I still do not understand “nodes” , or where to find my hard drives.

  13. it is a useful article to those who don’t know any about the topic.thank u

  14. In reply to Rob, he probably doesn’t realize that these directory names originated in UNIX from the beginning, when the normal user terminal was a Model 10 Teletype. Rob should have to use one of those for all his work for a few months (like I did), then he’d be a lot more sympathetic to the guys who created the original names.

  15. I like this post. I don’t think that he had made any wrong article. Because there are thousands of Linux distros are there. and obvious that there are many many improvement in every old version. So directory structure might be not same in every distributions. It is just a basic structure which is probably defined by Mr.Linus Torvald.

  16. hey, this article is really nice for me and new users of linux, it helped my research. Thanx

Leave a comment

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