Wednesday 21 November 2012

Linux File System Structure

What is file system?
-File System is nothing but structured set of files and directories which operating system uses as data structure.


     When user installs any software on Linux or Unix system,configuration files,manual pages (help pages),binaries, libraries goes under there respective directories like etc,bin,sbin etc. So user of the system should aware of where he should look for files .


For example if you have install FTP Server on your Linux machine then you should aware of 


-/etc/vsftpd.conf  : ftp configuration file.

-/var/ftp :contains users uploaded files.
-/etc/init.d/vsftpd : this is the ftp service.
-/var/log/vsftpd.log : log file for debugging issues and errors.

If know this structure you need not have to search again and again on internet for file locations.


Below I have explained Linux/Unix file system structure:




Linux File System
Linux File System


1) /  : Root Directory


  • Linux file system starts with /, the root directory which is parent directory for all other directories in Linux File System.
  • In days past it was also the home directory of 'root' user but now it has been given his own directory named '/root'.


2) /bin :User Binaries


  • contains essential system programs that must be available
  • these are needed by all the users of the system
  • these binary commands are like cp, mv, rm, cat, ls etc.

3) /sbin :System Binaries

  • contains binaries which  used for system maintenance and/or administrative tasks.
  • these binaries are essential for booting, restoring, recovering, and/or repairing the system
  • These binaries are used by system administrator for maintenance 
  • examples commands : shutdown, fastboot, fasthalt, fdisk, fsck, reboot, ifconfig, route etc.

4) /boot : Boot Related Files.


  • contains everything required for the boot process.
  • Example GRUB boot−loader,boot.b(boot sector) ,config−kernel−version etc.

5) /dev  :All Hardware Device files


  • contains all device files.
  • very interesting directory that highlights one important aspect of the Linux filesystem − everything is a file or a directory.Look through this directory and you should hopefully see
  • /dev/cdrom : CD -ROM
    /dev/fd0      : floppy drive
    /dev/hda1   : can be hard disk partition 1 like C: on windows

6) /etc: Configuration Files

  • contains all configuration files of installed programs.
  • this directory contains init.d and xinit.d directory which contains some services/daemon processes which user can  start,stop,restar. Contains services like  ftpd ,mysqld,network,sshd.
  • Contains configuration files like : crontab ,ftpuser,host.conf,yum.conf

7) /lib : Library To Run Executable Binaries

  • contains library to run executable binaries in bin,sbin etc.
  • similar to windows DLL files. These file names contains extension *.so.
  • e.g. libcap.so.22, libc.so.6

8) /media : Removable Media Files

  • contains files related to the removable media like usb drive,cd-rom,floppy.
  • temporary mount directory for removable devices.

9) /mnt: User Binaries

  • Temporarily  directory where user mount their filesystems or devices.
  • Mounting is the process by which you make a filesystem available to the system.
  • e.g System user can mount pen-drive under /mnt directory. so /mnt will have directory containing pen drive directory like /mnt/my_kingston

10) /opt : Optional Packages

  • reserved for all the software and add−on packages that are not part of the default installation.

11) /usr: Unix System Resource

  • one of the most important directories in the system user should aware of.
  • contains all the user binaries, their documentation, libraries, header files, etc
  • If you are looking for binaries,libraries,doc,config files etc  then also check  /usr directory.It can be found under below directories:
    • /usr/bin : Contains binaries of program's like vi,gcc,mozilla etc.
    • /usr/etc : Configuration files.
    • /usr/lib  : Contains program libraries.
    • /usr/sbin : binaries for administrative use.
    • /usr/man : help man pages.
  • /usr/share : Contains shareable  files.
  • /usr/src : Holds kernal sources,header−files and documentation.
  • /usr/local : Contains files of applications which are used locally.


12) /var : Variable Data

  • Contains variable data like system logging files, mail and printer spool directories, temporary files etc.
  • e.g /var/log (all logs),/var/mail,/var/tmp,/var/spool,/var/lib (dynamic data libraries/files)


13) /tmp : Temporary Files

  • Contains temporarily required files.
  • Many programs use this to create temporary storage of data.

14) /proc : Process Information Pseudo−file System

  • Doesn't contain 'real' files but runtime system information.
  • e.g. system memory, devices mounted, hardware configuration, etc

15) /srv: Service Data

  • Contains service related data.
  • e.g. /srv/ftp contains ftp service related data.

16) /root: Home Directory Of Root User

  • home directory of the System Administrator, 'root'.

17) /lost+found: Recovered files

  • Holds recovered files when system crash happens.

No comments:

Post a Comment