Linoob Forums

Full Version: Linux Directory Structure & Filesystem Hierarchy
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
For new users who migrate from Windows platform to linux, the linux filesystem seems confusing at first. But dont worry, here is a quick guide on understanding Linux (Ubuntu) Filesystem.

The Linux Filesytstem is very organized and easy to understand. The first thing you should know when working with linux, is that everything is treated as either a file or directory. Even hardware is considered a file by linux and all your hardware devices are located in the /dev directory.

Another thing that confuses windows users, is the fact that linux dosen’t use drive letters to distinguish between different partitions and devices. The 'root' of your filesystem is '/' whereas in windows it would most probably be C:\ . Drives in linux are “mounted” to directories where their data can then be accessed.

Sounds strange right? Well yes it does if you come from a windows environment, where the entire operating system is consolidated onto a single drive. However, with linux and the ability to mount devices as directories, it gives the end user much greater flexibility in splitting up their operating system over several drives or partitions.

To understand what I mean when I say that this approach in mounting drives grants flexibility, I must first explain the different folders in linux and what they store.

[Image: filesystemhierarchyhb8.jpg]

/ or root: This is the root folder, all other folders come under root.. think of it as C:\ in a Windows context. The contents of the root filesystem must be adequate to boot, restore, recover, and/or repair the system.

/bin : This folder contains all the user-essential binaries (programs) that are needed to administer and run your linux system… delete this folder and your system is broken. It contains commands that may be used by both the system administrator and by users, but which are required when no other filesystems are mounted

/boot: This folder contains configuration files and other necessary files that are needed by the bootloader. Thus /boot stores data that is used before the kernel begins executing user-mode programs. This may include saved master boot sectors and sector map files.

/dev: This folder contains special or device files. Be careful while working with it.

/etc: This folder contains all the configuration files used by the system, you can also start and stop services from here. It contains the following :
opt - Configuration for /opt
X11- Configuration for the X Window system (optional)
sgml- Configuration for SGML (optional)
xml- Configuration for XML (optional)


/home: This folder contains the home folders of all the normal (non – root ) users on the system .. think of it as my documents in windows. It is clearly a site-specific filesystem & setup will differ from host to host.

/lib: This folder contains essential shared libraries and kernel modules. This directory contains those shared library images needed to boot the system and run the commands in the root filesystem, ie. by binaries in /bin and /sbin.

/media: This is a mount point for removable media. This directory contains subdirectories which are used as mount points for removeable media such as floppy disks, CDroms, thumb drives etc.

/mnt: This is a mount point for a temporarily mounted filesystems. This directory is provided so that the system administrator may temporarily mount a filesystem as needed. The content of this directory is a local issue and should not affect the manner in which any program is run.

/opt: This folder contains add on softwares. A package to be installed in /opt must locate its static files in a separate /opt/<package> or /opt/<provider> directory tree, where <package> is a name that describes the software package and <provider> is the provider's registered name.

/sbin: This folder contains binaries that can only be run as the root user (“superuser”)

/tmp: This folder contains temporary files that are created while browsing, video buffering, system updates etc. and all the data is erased on reboot.

/usr: This folder and its subfolders contains user installed programs, utilities and libraries. Utilities used for system administration (and other root-only commands) are stored in /sbin, /usr/sbin, and /usr/local/sbin. /sbin contains binaries essential for booting, restoring, recovering, and/or repairing the system in addition to the binaries in /bin.

/var: The /var contains data that is changed when the system is running normally. It is specific for each system, i.e., not shared over the network with other computers.

/root: This folder contians the root user’s files. The root account's home directory may be determined by developer or local preference, but this is the recommended default location.

/proc: This is a psuedo folder, that contains information about the linux kernel and hardware that is updated in realtime.

/srv: It contains data for services provided by this system. /srv contains site-specific data which is served by this system.

Now, things are clear in front of you what different directories are there and what are their functions. All these collectively make the Linux Filesystem. We can actually mount a seperate hard drive for each of these directories. For example, your /home can be put on another harddrive than your / which means that you can easily recover your personal files if the harddrive on / fails because the harddrive mounted to your /home folder is seperate from the one that is mounted to your /. Simlarly /boot can also be made a separate paritition. It helps in easy management of bootloaders in dual-boot scenarios.
So, now you have a basic understanding of the Linux filesystem and we are sure it will help you understanding linux OS better. You can get details of each one, just google it. Smile

Njoy!
Reference URL's