Basics of Linux File System Heirarchy

FHS:

In 1994, FHS(Fileystem Hierarchy Standard) was proposed, it describes the directory structure of UNIX and UNIX-like systems(Linux). Before FHS was proposed, there had been UNIX-like operating systems which had their own standards. Today almost every UNIX-like systems notable Linux distros follow these guidelines.

The most common file hierarchy structure looks as below:

/
  /bin
  /boot
  /dev
  /etc
  /usr
  /tmp
  /lib
  /proc
  /opt
  /sbin
  /mnt
  /var
  /root

root(/):
This is the primary direcotry, All the directories reside in this directory. The partition which the root file system resides on is mounted first during boot and the system will not boot if it doesn't find it.

/bin:
This directory contains binary files of fundamental utilities like mv, ls, cp etc.. commands. 

/boot    
The startup files and the kernel, vmlinuz. In some recent distributions also grub data. Grub is the GRand Unified Boot loader and is an attempt to get rid of the many different boot-loaders we know today.

/dev    
This directory contains device specific files like the usb, keyboard, mouse. So finding out a keyboard device file and piping in its specific code will resemble a key press. This is the best way to simulate user input like keyboard, mouse etc..

/etc    
Contains system configuration files, change to these files will be reflected to all users. For user specific configuration modify the ‘.config’ directory present in user home directory.

/home    
This is the home directory where user data is stored. Each user gets a directory with directory name as user name.

/lib    
Library files, includes files for all kinds of programs needed by the system and the users.

/lost+found    
Every partition has a lost+found in its upper directory. Files that were saved during failures are here.

/mnt    
Standard mount point for external file systems, e.g. a CD-ROM or a digital camera.

/opt    
Third party software files will be stored here.

/proc    
A virtual file system containing information about system resources. Most commands like ‘top’, ‘ps’ etc..parse the files present in /proc to get processes information.

/root    
Home directory of root user. This is different from ‘/’ which is referred as root directory.

/sbin    
Programs for use by the system and the system administrator.

/tmp    
This directory gets cleaned on every bootup. Used as temporary file storage.

/usr    
Programs, libraries, documentation etc. for all user-related programs.

/var    
Storage for all variable files and temporary files created by users, such as log files, the mail queue, the print spooler area, space for temporary storage of files downloaded from the Internet, or database specific data.

Tip:
We can simply backup the whole filesystem excluding the /proc, /tmp and /dev as they are irrelevant on every boot. To backup the system it’s better to use ‘rsync’ command which has features to compress, doesn’t alter permissions etc..

rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /path/to/backup/folder

Posted On 30 March 2014 By MicroPyramid


Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
Understanding Logstash Parsing Configurations and options

In This Tutorial we will learn to customize Logstash to parse any type of Log Files. Logstash helps us to process logs and other event ...

Continue Reading...
How to backup and restore mysql, postgresql and mongodb databases

Data loss can happen when we accidentally delete the files, or when server crashes or system fails, or when we applied migrations to the data ...

Continue Reading...
Setting Up Sentry - Web Application Event Tracking platform

When you want to track your exception and log mesages in a UI rather than storing it in a file(which we usually do), we can ...

Continue Reading...
open source packages

Subscribe To our news letter

Subscribe and Stay Updated about our Webinars, news and articles on Django, Python, Machine Learning, Amazon Web Services, DevOps, Salesforce, ReactJS, AngularJS, React Native.
* We don't provide your email contact details to any third parties