Linux Directory Structure Explained with Diagram

Linux Directory StructureIn Windows, most of us are familiar with filesystem structure and the directories with their role.

In Linux, as we know many distro's are available, but what remains almost same is the filesystem and directory structure .

Lets go into the filesystem and directory structure and throw some light on each directory and its use.

 

 

 

/ -  :

  • The starting point of your directory structure. This is where the Linux system begins.
  • Every other file and directory on your system is under the root directory.
  • Usually the root directory contains only sub directories, so it's a bad idea to store single files directly under root.

1. /bin - User Binaries :

  • This directory contains user applications and a variety of other things for them, like their source codes, and pictures, docs, or config files they use.
  • /usr is the largest directory on a Linux system, and some people like to have it on a separate partition.

2. /boot - Boot Loader Files :

  • This is the place where Linux keeps information that it needs when booting up.
  • Contains kernel, grub files, etc

3. /dev - Device Files

  • The devices that are available to a Linux system. In Linux, devices are treated like files and you can read and write devices like they were files.
  • For examples, /dev/fd0 is your first floppy drive, /dev/cdrom is your CD drive, /dev/hda is the first IDE hard drive, and so on.
  • All the devices that a Linux kernel can understand are located under /dev, and that's why it contains hundreds of entries.

4. /etc - Configuration Files :

  • The configuration files for the Linux system. Most of these files are text files and can be edited by hand.
  • For examples, /etc/fstab, /etc/passwd, /etc/inittab, etc

5. /home - Home Directories :

  • This is where users keep their personal files. Every user has their own directory under /home, and usually it's the only place where normal users are allowed to write files.
  • You can configure a Linux system so that normal users can't even list the contents of other users' home directories.
  • For examples, /home /mark , /home/joe

6. /lib - Library (System and Shared)

  • The shared libraries for programs that are dynamically linked.
  • The shared libraries are similar to DLL's on Winblows.
  • Library filenames are either ld* or lib*.so.*

7. /media - Removable Media Devices :

  • The temporary mount directory for removable devices.
  • For example, /media/cdrom for CD-ROM, /media/cdrecorder for CD writer

8. /mnt - Mount Directory :

  • This directory is used for temporary mount points.
  • The different physical storage devices (like the hard disk drives, floppies, CD-ROM's) must be attached to some directory in the file system tree before they can be accessed. This attaching is called mounting, and the directory where the device is attached is called the mount point.
  • The /mnt directory contains mount points for different devices, like /mnt/floppy for the floppy drive, /mnt/cdrom for the CD-ROM, and so on. However, you're not forced to use the /mnt directory for this purpose, you can use whatever directory you wish.
  • Actually in some distros, like Debian and SuSE, the default is to use /floppy and /cdrom as mount points instead of directories under /mnt.

9. /opt - Optional Addon Applications :

  • The /opt directory contains add-on applications from individual vendors.
  • Add-on applications should be installed under either /opt/ or /opt/ sub-directory.

10. /sbin - System Binaries :

  • Most system administration programs are stored in these directories.
  • In many cases you must run these programs as the root user.
  • For example, reboot, iptables

11. /srv - Service Data :

  • /srv contains site-specific data which is served by this system.
  • For example, /srv/physics/www, /srv/compsci/cvs

12. /tmp - Temporary Directory :

  • The /tmp directory must be made available for programs that require temporary files.
  • Files under this directory are deleted when system is rebooted.

13. /usr - User Programs :

  • /usr is the second major section of the filesystem. /usr is shareable, read-only data.
  • That means that /usr should be shareable between various FHS-compliant hosts and must not be written to.
  • Any information that is host-specific or varies with time is stored elsewhere.
  • Large software packages must not use a direct subdirectory under the /usr hierarchy.

14. /var - Variable Files :

  • This directory contains variable data that changes constantly when the system is running.
  • For sample, /var/log, /var/spool, /var/mail

15. / - Root :

  • The superuser's (root's) home directory. Don't confuse this with the root directory (/) of a Linux system.

16. /proc - Process Information :

  • This is a special directory. Well, actually /proc is just a virtual directory, because it doesn't exist at all!
  • It contains some info about the kernel itself. There's a bunch of numbered entries that correspond to all processes running on the system, and there are also named entries that permit access to the current configuration of the system. Many of these entries can be viewed.
  • For example, /proc/pid

 

If any feedback, queries are always welcome!

Share on FacebookShare on Google+Tweet about this on TwitterShare on StumbleUponShare on LinkedInShare on TumblrDigg thisPin on PinterestShare on RedditEmail this to someonePrint this page

About Abhijit Sandhan

Abhijit Sandhan
Loves Linux, Blogging, Traveling, Hiking and sharing the knowledge!

3 comments

  1. really nice explanation and easy to understand

  2. understanding made easy.

  3. Wonderful explanation and very easy to understand cPanel Linux Directory Structure

Leave a Reply

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

*

CAPTCHA Image

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>