Saturday 19 January 2013

Difference between Hard Link and Soft Link


Difference Between Hard Link and Soft Link:-


HARD LINK:-
 Hard link is acts like a mirror copy of the original file. These links share the same inodes.
Changes made to the original or hard linked file will reflect the other. When you delete hard link nothing will happen to the other. Hard links can’t cross file systems.

Features:-
1)      Have same inodes number.
2)      Ls –l command shows all the links with the link column shows  number of links.
3)      Links have actual file contents.
4)      Removing any link, just reduces the link count, but doesn’t affect other links.
5)      You cannot create a hard link for a directory.
6)      If original file is removed then the link will still show the content of the file.

Example:-
HardLink:-
[root@localhost ]# mkdir test
[root@localhost ]# cd test/
[root@localhost test]# ls
[root@localhost test]# touch test1
[root@localhost test]# ln test1  test2
[root@localhost test]# ls -il  test1  test2
1335106 -rw-r--r--. 2 root root 0 Jan 19 16:29 test1
1335106 -rw-r--r--. 2 root root 0 Jan 19 16:29 test2
[root@localhost test]#
From the output you can noticed that both file has same inode number and Size also same.
Now remove test1 and check the content of test2 file.
[root@localhost test]# rm  test 1
rm: remove regular empty file `test1'? y
[root@localhost test]# cat test2
You will still be able to same content in test2.
………………………………………………………………………………………………………………………………………………………………
Soft Link:-
Soft Link is actual link to the original file. These Links will have a different inodes Value.
Softlink points to the original file so if original file is deleted the soft link fails. If you delete
The soft link, nothing will happen to file. The reason for this is, the actual file or directory’s
Inode is different from the “Soft Link” created file’s inode,Hard links can cross file System.

Features:-
1)      Soft links have different inodes number.
2)      Ls –l command shows all link with second column value 1 and the link points to original file.
3)      Soft Link contains the path for original file and not the contents.
4)      Removing soft link doesn’t affect anything but removing but removing original file, the link points to the nonexistent file.
5)      A soft link can link to a directory.

Example:-
[root@localhost test]# ln -s  test2  test3
[root@localhost test]# ls -li  test2   test3
1335106 -rw-r--r--. 1 root root 0 Jan 19 16:29  test2
1336783 lrwxrwxrwx. 1 root root 7 Jan 19 16:39 test3 -> test2
[root@localhost test]#
From the output you can notice that the both file have different inode number and Permissions.
[root@localhost test]# cat  test2
[root@localhost test]# cat test3
Now remove the original file:
[root@localhost test]# rm  test2
rm: remove regular empty file `test2'? y
[root@localhost test]# ls
test3
It will display Symbolic link  test3 but if you try to list the contents  it will tell you that there is no such file getting error message.
[root@localhost test]# cat  test3
cat: test3: No such file or directory
[root@localhost test]# ls

Saturday 5 January 2013

Simple Steps to install wordpress on Centos


Wordpress Installation steps:-

1) [root@linuxnotes~] # wget http://wordpress.org/latest.tar.gz
2) [root@linuxnotes~] #  tar -xvzf latest.tar.gz
3) [root@linuxnotes~] # cd wordpress/
4) [root@linuxnotes~] # rpm –qa mysqld*

Note:- If showing mysql package then no need to install otherwise refer the step no 5.

5) [root@linuxnotes~] # yum install mysqld* -y
6) [root@linuxnotes~] # /etc/init.d/mysqld status

Note:-  If mysql status showing stopped  then first start the service and then refer the step no 7.

7) [root@linuxnotes~] # mysql –u root –p
8) Enter password:  ******
9) Mysql> show databases;
10) Mysql > mysql> show databases;   // To check whether  existing database-name  is  worpress.
                +--------------------+
                | Database           |
               +--------------------+
                | information_schema |
                | collage               |
                | Employee           |
                | Alfresco           |
                | Asterisk           |
                | MySQL              |
                | Test               |
                |  Account               |
                +--------------------+
                8 rows in set (0.12 sec)

11) mysql> CREATE DATABASE wordpress;
12) mysql> CREATE USER wordpressuser@localhost;
Note :- To verify  created  wordpressuser by using following  steps no 13,14 and 15.
13) mysql> use mysql;
14) mysql> show tables;
15) mysql> select * from user;
16) mysql> set password for wordpressuser@localhost=password('*******');
17) mysql> GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY '******';
18) mysql> flush privileges;
19) mysql> show databases;
               +--------------------+
                | Database           |
               +--------------------+
                | information_schema |
                | collage              |
                | Employee           |
                | Alfresco           |
                | Asterisk           |
                | MySQL              |
                | Test               |
                | Wordpress          |
                | Account               |
                +--------------------+
                9 rows in set (0.12 sec)

         
20) mysql> exit
21) [root@linuxnotes~] # cd  /downloads/wordpress
22) [root@linuxnotes~] # ls
23) [root@linuxnotes~] # cp  -r  wp-config-sample.php  wp-config.php
24) [root@linuxnotes~] # vi  wp-config.php

Note:- Edit wp-config.php file and  change the following lines
/** The name of the database for WordPress */  
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpressuserName');

/** MySQL database password */
define('DB_PASSWORD', '*******');

save and exit.

25) [root@linuxnotes~] # cp –r  wordpress/*  /var/www/html

Check the network config file:-

26)  [root@linuxnotes~] #  Vi /etc/hosts
#127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
 ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
“Your  ip address ”  localhost localhost.localdomain

27) [root@linuxnotes~] #  /et c/init.d/network  restart
28)    [root@linuxnotes~] #  /et c/init.d/mysqld  restart
29) [root@linuxnotes~] #  /etc/init.d/httpd   restart
30) Finally check  in browser :-  http://ipaddress