1834070 Members
3037 Online
110063 Solutions
New Discussion

Re: Doubt on ln command

 
SOLVED
Go to solution
Ramsunder S
Occasional Advisor

Doubt on ln command

Hi,
I have a file which has a link count of 2. Is there any way I can figure out the two links that reference this file?

Thanks.
Regards,
Ram.
8 REPLIES 8
Nick Wickens
Respected Contributor

Re: Doubt on ln command

I think you can do this.

1. Do an ll command against the file and note the minor number ie - 0x0f005c

2. Enter this command -

ll -R / |grep 0x0f005c
Hats ? We don't need no stinkin' hats !!
Justo Exposito
Esteemed Contributor

Re: Doubt on ln command

Hi Ram,

You can try with find:

find / -type l -name "filename" -u "ownername" -print

Regards,

Justo.
Help is a Beatiful word
Nick Wickens
Respected Contributor
Solution

Re: Doubt on ln command

Sorry had Informix hat on and was thinking of block and character device files - suggestion does not apply to normal files.

Have a look at the find command -linkedto

ie find / -linkedto filename
Hats ? We don't need no stinkin' hats !!
Deepak Extross
Honored Contributor

Re: Doubt on ln command

The inode number of all links will be the same.

You can do a ll -i to see the inode number of the file (first column) and then search for files with the same inode number.
Olav Baadsvik
Esteemed Contributor

Re: Doubt on ln command


Hi,

Do the following. Lets say your filename
is file1.txt

ls -li file1.txt
This will show you the inode number which
you then use in a find command:

find -xdev -inum

The startpoint should be the mountpoint of the
filesystem holding file1.txt.
As the link-count is 2 this command should
return two hits, file1.txt beeing one of them.

Regards
Olav
Ramsunder S
Occasional Advisor

Re: Doubt on ln command

Thank you everyone for your replies.

Justo,
the -u switch does not seem to work on HP-UX 11.0.

Regards,
Ram.
Justo Exposito
Esteemed Contributor

Re: Doubt on ln command

Hi Ram,

Sorry the option is -user uname.

You can see it in the manpage for find.

Regards,

Justo.
Help is a Beatiful word
H.Merijn Brand (procura
Honored Contributor

Re: Doubt on ln command

Why has noone mentioned ncheck yet: *the* util for this

a5:/tmp 105 # banner Help > xx
a5:/tmp 106 # ln xx yy
a5:/tmp 107 # ls -il xx
183 -rw-rw-rw- 2 merijn softwr 232 Sep 2 18:33 xx
a5:/tmp 108 # ncheck -i 183 /dev/vg00/tmp
/dev/vg00/tmp:
183 /xx
183 /yy
a5:/tmp 109 #
Enjoy, Have FUN! H.Merijn