Tuesday, 15 April 2014

Centos 6/RHEL directories and usage.


The Linux directory tree starts at "\", with all other directories below it. Each directory has a specific use and contains the necessary sub files and folders to facilitate this.


Centos 6 directories


/bin

Contains small executable programs (binaries) which are often considered to be part of the operating system itself – but they are not. For instance, when you type the ls command at a prompt, to list the contents of a directory, Linux executes the ls program that is located in the bin directory. This directory is, broadly speaking, equivalent to the C:\ Windows directory in Microsoft’s Windows.




/sbin

Contains executable system programs (binaries) that are only used by the root superuser and by Linux when the system is booting up or performing system recovery operations. For instance, the clock program that maintains the system time when Linux is running is located in the /sbin directory. This directory is equivalent to the C:\Windows\system directory in Windows.




/lib

Contains binary library files which are used by the executable programs in the /bin and /sbin directories. These shared libraries are particularly important for booting the system and and executing commands within the root file system. They are roughly equivalent to the DLL (Dynamic Link Library) files in Windows but are all in one place. Having a specific directory for support libraries avoids the common problem in Windows where multiple libraries have been installed and the system has been confused about which one to use.




/dev

Dev contains special file system entries which represent devices that are attached to the system. These allow programs access to the device drivers which are essential for the system to function properly - although the actual driver files are located elsewhere. For instance, typically the entry /dev/fd0 would represent the floppy drive if used and an entry of /dev/cdrom0 represents the CD drive.




/boot

This contains the Linux kernel - the heart of the operating system. Many people incorrectly use the term "operating system" to refer to the Linux environment but it is the KERNEL which is the operating system. It is the program which controls access to all the hardware devices the computer supports and allows multiple programs to run concurrently and share that hardware. Typically the program is called "vmlinuz" - other programs complementing the kernel are located in the /bin and /sbin directories.





/etc

Contains system configuration files storing information about everything from user passwords and system initialization to screen resolution settings.


All these are plain text files that can be viewed in any text editor such as gedit or vim - there should not be any binary files in this directory. They control all the configuration settings which are not user-specific. So these files are roughly equivalent to the combination of .ini files and the Registry entries found within the Windows operating system.



/proc 


Contains special files that relay information to and from the kernel. The hierarchy of "virtual files" within this directory represent the current state of the kernel - allowing applications and users to peer in to the kernels view of the system. As an example type in to the terminal



more /proc/cpuinfo



more /proc/meminfo



To obtain relevant information about cpu and memory.



Virtual files are listed as zero bytes and are time stamped to reflect the fact that they are constantly updating.



/mnt

Contains sub-directories that act as gateways to temporarily mounted file systems. This is the default location where most distros attach mounted file systems to the Linux directory tree.


Typically, when peripheral drives have been mounted, the /mnt/cdrom directory lets you access files on a CD-Rom loaded into the CD Drive. If you have a dual boot set up then /mnt/windows can reveal files on the Windows partition although accessibility can be restricted on NTFS file systems.



/usr

This contains sub directories storing programs that can be run by any user of that system. For instance, games, word processors and media players. It is broadly speaking, the equivalent of C:<Program Files in Windows. The /usr/local sub--directory is intended for use by the system administrator, when installing software locally, to prevent it being overwritten when the system software is being updated.




/var

This contains variable data files which store information about ongoing system status, particularly logs of system activity. The system administrator (root superuser) can type the following command at a root prompt to see a record of system activity messages




more /var/log/messages



/home

Contains a sub-directory for each user account to store personal data files. If there is a user account called @fred@ there will be a /home/fred directory where that user can store personal files - others can not save files there. This directory is where you store all your working documents, images and media files and is the roughly equivalent of the My Documents folder within Microsoft's Windows operating system.




/tmp

Contains temporary files that have been created by running programs/ Usually these are deleted when the program gets closed but some do get left behind - periodically these should be deleted. This directory corresponds to the C:<Windows/Temp folder in Windows.




/root

This is the home directory for the root account superuser - for security reasons regular users cannot access this directory.. If you log in to Linux as root and open that accounts home directory it's at/root rather than a sub directory of /home like a regular user.




/initrd

Contains only a text file warning that this directory should not be deleted. It is used during the boot process to mount the Linux file system itself. Removing this directory will leave the computer unable to boot Linux and will generate a kernel panic error.




/opt

Contains nothing initially,but this directory provides a special area where large static application software packages can be deployed. A package placing files in /opt creates a sub-directory bearing the same name as the package. This sub-directory contains files that would otherwise be scattered around the file system, giving the system admin an easy way to determine the role for each file.. For instance, if "example" is the name of a particular software package in the /opt directory, then all its files could be placed within sub-directories of the /opt/example directory. Binaries would be in /opt/example/bin, man pages in /opt/example/man etc. 


Usually the application can be removed by simply deleting the contents of the directory. 

As you can see in the above image there may be additional directories such as selinux (security) srv (web server) which accommodate extra functionality depending upon your set up.

See also partitioning and directories.