Wednesday, May 23, 2012

Linux Directory Structure


Contains the basic shell commands that may be used both by root and by other users. These commands include ls, mkdir, cp, mv, rm, and rmdir. /bin also contains Bash, the default shell.


Contains data required for booting, such as the boot loader, the kernel, and other data that is used before the kernel begins executing user mode programs.


Holds device files that represent hardware components. 


Contains local configuration files that control the operation of programs like the X Window System. The /etc/init.d subdirectory contains scripts that are executed during the boot process.


Holds the private data of every user who has an account on the system. The files located here can only be modified by their owner or by the system administrator.


Contains essential shared libraries needed to boot the system and to run the commands in the root file system. The Windows equivalent for shared libraries are DLL files.


Contains mount points for removable media, such as CD-ROMs, USB sticks, and digital cameras (if they use USB). /media generally holds any type of drive except the hard drive of your system. As soon as your removable medium has been inserted or connected to the system and has been mounted, you can access it from here. 


This directory provides a mount point for a temporarily mounted file system. root may mount file systems here.


Reserved for the installation of additional software. Optional software and larger add-on program packages can be found there. 


Home directory for the root user. Personal data of root is located here.


As the s indicates, this directory holds utilities for the superuser. /sbin contains binaries essential for booting, restoring, and recovering the system in addition to the binaries in /bin.


Holds data for services provided by the system, such as FTP and HTTP.


This directory is used by programs that require temporary storage of files.


/usr has nothing to do with users, but is the acronym for UNIX system resources. The data in /usr is static, read-only data that can be shared among various hosts compliant to the Filesystem Hierarchy Standard (FHS). This directory contains all application programs and establishes a secondary hierarchy in the file system. KDE4 and GNOME are also located here. /usr holds a number of subdirectories, such as /usr/bin, /usr/sbin, /usr/local, and /usr/share/doc.


Contains generally accessible programs.


Contains programs reserved for the system administrator, such as repair functions.


In this directory, the system administrator can install local, distribution-independent extensions.


Holds various documentation files and the release notes for your system. In the manual subdirectory, find an online version of this manual. If more than one language is installed, this directory may contain versions of the manuals for different languages.

Under packages, find the documentation included in the software packages installed on your system. For every package, a subdirectory /usr/share/doc/packages/packagename is created that often holds README files for the package and sometimes examples, configuration files, or additional scripts.


Whereas /usr holds static, read-only data, /var is for data which is written during system operation and thus is variable data, such as log files or spooling data. For example, the log files of your system are in /var/log/messages (only accessible for root).

Configure High Availability Cluster (Heartbeat) On Linux

Refer the following steps :

Number of nodes : Two (node1 and node2)
Clustering software : Heart Beat
Service to be high available : http
IP : to be configured on node1 to be configured on node2 for Heart Beat clustering enabled services(http etc)

1. setup the above two IP on the server and make it sure that uname -n returns node1 or node2
2. yum install heartbeat
make sure that you installed :


3. configure heartbeat on two node cluster. We will deal with three files. These are:


Now moving to our configuration. But there is one more thing to do, that is to copy these files to the /etc/ha.d directory. In our case we copy these files as given below:

cp /usr/share/doc/heartbeat-2.1.2/authkeys /etc/ha.d/
cp /usr/share/doc/heartbeat-2.1.2/ /etc/ha.d/
cp /usr/share/doc/heartbeat-2.1.2/haresources /etc/ha.d/

4. Now let's start configuring heartbeat. First we will deal with the authkeys file, we will use authentication method 2 (sha1). For this we will make changes in the authkeys file as below.

vi /etc/ha.d/authkeys

Then add the following lines:

auth 2
2 sha1 test-ha

Change the permission of the authkeys file:

chmod 600 /etc/ha.d/authkeys

5. Moving to our second file ( which is the most important. So edit the file with vi:

vi /etc/ha.d/

Add the following lines in the file:

logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
initdead 120
bcast eth0
udpport 694
auto_failback on
node node1
node node2

Note: node1 and node2 are the output generated by

uname -n

6. The final piece of work in our configuration is to edit the haresources file. This file contains the information about resources which we want to highly enable. In our case we want the webserver (httpd) highly available:

On node 1 :-

vi /etc/ha.d/haresources
Add the following line:
node1 httpd

On node 2 :-

vi /etc/ha.d/haresources
Add the following line:
node2 httpd

7. Copy the /etc/ha.d/ directory from node1 to node2 :

scp -r /etc/ha.d/ root@node2:/etc/

8. As we want httpd highly enabled let's start configuring httpd :

vi /etc/httpd/conf/httpd.conf

Add this line in httpd.conf:


9. Copy the /etc/httpd/conf/httpd.conf file to node2:

scp /etc/httpd/conf/httpd.conf root@node2:/etc/httpd/conf/

10. Create the file index.html on both nodes (node1 & node2):

On node1:

echo "node1 apache test server" > /var/www/html/index.html

On node2:

echo "node2 apache test server" > /var/www/html/index.html

11. Now start heartbeat on the primary node1 and slave node2:

/etc/init.d/heartbeat start

12. Open web-browser and type in the URL:

It will show node1 apache test server.

13. Now stop the hearbeat daemon on node1:

/etc/init.d/heartbeat stop

In your browser type in the URL and press enter.

It will show node2 apache test server.

14. We don't need to create a virtual network interface and assign an IP address ( to it. Heartbeat will do this for you, and start the service (httpd) itself. 

Your Reviews/Queries Are Accepted