Wednesday, August 31, 2011

Linux Directory Structure


If you are working in Linux for the very first time,you will be confused about the directory structure. But dont worry we will make it clear to you here.

If you work on a Windows pc,you have seen that there are three folders created by default in your C:\ drive;Windows,Program files and Document and settings. Windows folder keeps OS own files,Program files stores the installed programs files whereas Document and Setting folder keeps users personal settings and personal data.


But in Linux scenario is a little bit different. In window, where we call Folders,are called “Directories” here. All the files are stored in directories which can have many other subdirectories. In Linux,everything stored under the root directory and '/' [forward slash ] is the symbol of root. Whereas in Windows everything stored in 'C:\' [back slash].


Now have a look at the Linux Directory Structure.


/

It is also know as root. All other directories in linux are subdirectories of / [root].It is the top level directory of Linux Directory Hierarchy. Only the root user has the right to write into this directory.


/bin

This directory contain shells like bash and csh and executable commands which can run by both normal users and root user. Commands like touch, mkdir, cat, vi, cp, mv etc.. are stored in this directory. These commands are very necessary bcoz even in single user mode you can run these commands to rescue your system .


/sbin

This directory too contain binary executable commands but these commands can only be run by the root user. Command stored in this directory are used for the system administration and maintenance purpose. Commands like fdisk, iptables, reboot, mdadm, fsck, ifconfig are stored in this directory.


/home

This is the home directory of a normal user. Every user who has an account on the system,has its own private data in this directory. This directory can be modified by only superuser or the owner of the directory. Like user test1 & test2 will have their own directory like /home/test1 and /home/test2.


/root

This is the home directory of the superuser or root. Root's own private data is stored in this

directory. All the administrative task are performed by loging in to this directory. It is advisable that you should not login with the root access as any small mistake can make your system unbootable.

/etc

This is the main configuration directory of your linux os. All important network and other services are configured into this directory. Some major server configuration files like samba.conf, httpd.conf, dhcpd.conf are configured in this directory.


/var

This is the variable directory of your system. Variable data is a data which repetitively changes.

Information about system logs,mails,print-queue and database is stored in this directory.

Running system operations uses this directory thus the data changes continuously.


/tmp

This is the temporary directory of your linux os. The applications and programs which run on your system,creates some temporary files into this directory. But as the name says itself that it is temporary,the data is flushed from here once you restart your system.


/opt

This is the optional directory where all the softwares and add-ons are stored. This is the default software installation directory of your system and usually you will find softwares like starOffice ,teamviewer and kde installed here.


/proc

This is the virtual directory or Pseudo filesystem which stores information of system processes and the kernel. Like you can find information about cpu and memory in /proc/meminfo and /proc/cpuinfo.


/dev

This is the device directory of your system. Every device in linux is assumed as files.This directory contain device files that are required to communicate with various hardwares attached to your system like USB and CD/DVD.


/lib

This directories contains the library files that are required by system programs to run and to boot the system. If you wish to develop the kernel of the os, you will be using the libraries. These libraries are same as Windows DLL files.


/boot

These directory contain the booting files that are necessary to boot your linux os. Files such as vmlinuz[kernel], grub, initrd etc.are placed here. If you delete any file from this directory ,your system can be unbootable.


/mnt

This is the temporary directory in which storage devices can be mounted. Mounting is a process by which you can assign a filesystem to a partition so that you can access that partition.


/media

This is the temporary directory in which removable media devices are mounted such as CD-ROM and USB devices. Whenever you insert your cd-dvd's into the cd-tray you can access them with this directory


/srv

This directory contain data files of server related processes. Data files of FTP and HTTP can be found here. Usually this directory is empty all the time.


/lost+found

This directory is used to recover any lost or corrupted data. If your system shutdown unexpectedly , the data can be corrupt or lost. In that case when your system goes through the FSCK[file system check],it is possibly that we can recover that data here.


/selinux

Selinux is Secured Enhanced Linux. This directory contain data related to linux security.



No comments:

Post a Comment