Monday, August 4, 2014

About Linux Directory Structure and Important Files Paths

Overview of the FHS

Everything in Linux can be reduced to a file. Partitions are associated with files such as /dev/hda1. Hardware components are associated with files such as /dev/modem. Detected devices are documented as files in the /proc directory. The Filesystem Hierarchy Standard (FHS) is the official way to organize files in Unix and Linux directories.

Linux file system and directory structure


Several major directories are associated with all modern Unix/Linux operating systems. These directories organize user files, drivers, kernels, logs, programs, utilities, and more into different categories. The standardization of the FHS makes it easier for users of other Unix-based operating systems to understand the basics of Linux. Every FHS starts with the root directory, also known by its label, the single forward slash (/). All of the other directories shown in Table are subdirectories of the root directory. Unless they are mounted separately, you can also find their files on the same partition as the root directory.

A standard Linux distribution follows the directory structure as provided below with Diagram and explanation.

http://www.tecmint.com/wp-content/uploads/2013/09/Linux-Directory-Structure.jpeg

Each of the above directory (which is a file, at the first place) contains important information, required for booting to device drivers, configuration files, etc. Describing briefly the purpose of each directory, we are starting hierarchically.
  1.  /bin : All the executable binary programs (file) required during booting, repairing, files required to run into single-user-mode, and other important, basic commands viz., cat, du, df, tar, rpm, wc, history, etc.
  2.  /boot : Holds important files during boot-up process, including Linux Kernel.
  3.  /dev : Contains device files for all the hardware devices on the machine e.g., cdrom, cpu, etc
  4.  /etc : Contains Application’s configuration files, startup, shutdown, start, stop script for every individual program.
  5.  /home : Home directory of the users. Every time a new user is created, a directory in the name of user is created within home directory which contains other directories like Desktop, Downloads, Documents, etc.
  6.  /lib : The Lib directory contains kernel modules and shared library images required to boot the system and run commands in root file system.
  7.  /lost+found : This Directory is installed during installation of Linux, useful for recovering files which may be broken due to unexpected shut-down.
  8.  /media : Temporary mount directory is created for removable devices viz., media/cdrom.
  9.  /mnt : Temporary mount directory for mounting file system.
  10.  /opt : Optional is abbreviated as opt. Contains third party application software. Viz., Java, etc.
  11.  /proc : A virtual and pseudo file-system which contains information about running process with a particular Process-id aka pid.
  12.  /root : This is the home directory of root user and should never be confused with ‘/
  13.  /run : This directory is the only clean solution for early-runtime-dir problem.
  14.  /sbin : Contains binary executable programs, required by System Administrator, for Maintenance. Viz., iptables, fdisk, ifconfig, swapon, reboot, etc.
  15.  /srv : Service is abbreviated as ‘srv‘. This directory contains server specific and service related files.
  16.  /sys : Modern Linux distributions include a /sys directory as a virtual filesystem, which stores and allows modification of the devices connected to the system.
  17.  /tmp :System’s Temporary Directory, Accessible by users and root. Stores temporary files for user and system, till next boot.
  18.  /usr : Contains executable binaries, documentation, source code, libraries for second level program.
  19.  /var : Stands for variable. The contents of this file is expected to grow. This directory contains log, lock, spool, mail and temp files.
Important configuration files form /etc directory 

File
Function
/etc/fstabLists the partitions and file systems that will be automatically mounted when the system boots.
/etc/groupContains local group definitions.
/etc/grub.confContains configuration parameters for the GRUB bootloader (assuming it's being used on the system).
/etc/hostsContains a list of hostname-to-IP address mappings the system can use to resolve hostnames.
/etc/inittabContains configuration parameters for the init process.
/etc/init.d/A subdirectory that contains startup scripts for services installed on the system. On a Fedora or Red Hat system, these are located in /etc/rc.d/init.d.
/etc/modules.confContains configuration parameters for your kernel modules.
/etc/passwdContains your system user accounts.
/etc/shadowContains encrypted passwords for your user accounts.
/etc/X11/Contains configuration files for X Windows.

0 comments:

Post a Comment