Monday, November 15, 2010

Linux Directory Structure

The first thing that troubles a Linux newcomer is the Linux directory structure. First thing that people need to understand is that Linux has one directory tree which starts at "/" (also known as "root directory" or simply "root") in contrast Windows has multiple directory trees, one for each partition and removable media.

Every formatted hard drive partition has a file system on it. These file systems are not required to be the same. In Windows each file system is mounted to a different drive letter, thus starting a new directory tree, whereas on Linux one file system is mounted on root i.e "/" and other file systems are mounted on subdirectories of the root file system, creating a single directory tree. The file system mounted on "/" is called Root File System.

Given below are the most important subdirectories of root directory:

/bin
This directory contains the programs(binaries) that are required during bootup. These programs may be run by root user as well as a normal user. There must be no subdirectory in /bin.

/sbin
This directory is similar to /bin as it also contains binaries that are required during bootup but these binaries can only be run by super user i.e root user.

/lib
This directory contains library files that are required by different binaries in /bin and /sbin.

/usr/bin
Similar to /bin except that it contains programs which are not required during bootup.

/usr/sbin
Similar to /sbin except that it contains programs which are not required during bootup.

/usr/lib
This directory contains library files that are required by different binaries in /usr/bin and /usr/sbin.

/home
This directory is analogous to "Documents & Settings" directory in Windows. It contains 1 directory per user known as home directory of that user. All user specific files, configuration, documents and etc are stored in the users home directory.

/boot
This directory contains boot loader files. Boot loader is a program that boots Linux.

/etc
This directory contains system wide configuration files e.g network configuration, XWindows configuration and etc.

/var
This directory contains variable files i.e the files whose content changes continually during the operation of a system. An example of such files are log files which can be found at /var/log directory

More on Linux Directory Structure can be found at Filesystem Hierarchy Stadard website and on Wikipedia

No comments: