Operating System - HP-UX
1748281 Members
3952 Online
108761 Solutions
New Discussion юеВ

Re: How to identify the harlink file

 
MD.IMTEYAZUL HASSAN
Contributor

How to identify the harlink file

How can i identify the harlink file
10 REPLIES 10
Jozef_Novak
Respected Contributor

Re: How to identify the harlink file

Hello,

do you mean a hard link ? If so, then use ls -i and the two files should have the same inode number.

J.
MD.IMTEYAZUL HASSAN
Contributor

Re: How to identify the harlink file

how do we identify which file is actual and which file is hardlink
Dennis Handly
Acclaimed Contributor

Re: How to identify the harlink file

>how do we identify which file is actual and which file is hardlink

There is no difference, except what's in your mind, if you created it.
Jozef_Novak
Respected Contributor

Re: How to identify the harlink file

Hard link, unlike a symbolic link is just another name for the same file. So there is no order which they should be referenced in.

J.
Bijeesh
Respected Contributor

Re: How to identify the harlink file

hi
both are having same inode number.And if you are making any changes to one of the file the other one also get changed.But if you delete one file the other one will not get deleted.
Jestin John Chacko
Regular Advisor

Re: How to identify the harlink file

For better understanding just see the figure attached

For a hard link to be created use ln and for softlink use ln -s

by looking at the inode number you can verify whether it is hardlink or softlink
Suraj K Sankari
Honored Contributor

Re: How to identify the harlink file

Hi,

Give "ls -l" to se the link file.

Suraj
subodhbagade
Regular Advisor

Re: How to identify the harlink file

Hi,

Hardlink is --

(1)Multiple name given to same data in same file system.

(2)eg
ln /tmp/a /tmp/b
here to check the hard link

cd /tmp
ls -l check ' l ' symbol for b

Regards,
Subodh.
Viktor Balogh
Honored Contributor

Re: How to identify the harlink file

here is an example:

# touch test
# ln test test2
# ls -li test*
98314 -rw-r--r-- 2 pranksterr users 0 2009-04-24 16:51 test
98314 -rw-r--r-- 2 pranksterr users 0 2009-04-24 16:51 test2
# rm test
# ls -li test*
98314 -rw-r--r-- 1 pranksterr users 0 2009-04-24 16:51 test2

the 3rd field right after the permissions in the output of ll/ls -l is the link count.
the -i option tells ls to show the inode numbers too. you can see that after i created a hard link (ln without -s) the link count were 2, and in the first field the inode numbers were matched. just think about it like you have the data on the disk only once, but you have a reference in two places.

after i deleted one of the link, the other remained and the link count were accordingly 1.

and a little note: hard link (without -s) are only allowed in a single filesystem, if you want to have link to another filesystem then you instead must make a symlink with 'ln -s'. (that's because the inode number is only uniqe in a single FS.)
****
Unix operates with beer.