[net.unix] How can I find where a link leads to

tower@inmet.UUCP (01/14/85)

Granted you have found the inode number via:
	ls -i
one can then use find with the -inum option to
locate all the directory entries.
Note that a find from / can take a veryyyyyyyy longgggggg time.

-len tower		UUCP:     {ihnp4,harpo}!inmet!tower
 Intermetrics, Inc.	INTERNET: ima!inmet!tower@CCA-UNIX.ARPA
 733 Concord Ave.
 Cambridge, MA  02138	(617) 661-1840
 U.S.A.

guy@rlgvax.UUCP (Guy Harris) (01/15/85)

> Granted you have found the inode number via:
> 	ls -i
> one can then use find with the -inum option to
> locate all the directory entries.
> Note that a find from / can take a veryyyyyyyy longgggggg time.

(BTW, "find -inum" is in all the version of "find" I've seen, although
Berkeley are the only people who bothered documenting it.)  In addition to
being slow, this 1) may have several false hits, as it looks for all files
with that inumber regardless of what file system they're on and 2) also may
not work if some of the directory entries pointing to that inode are in
directories that you have no read access to.  You could run it as superuser,
but then if you can run as superuser you should use "ncheck" which is lots
faster and searches only one filesystem (thus eliminating problems 1) and 2)).

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy

rpw3@redwood.UUCP (Rob Warnock) (01/15/85)

+---------------
| > ls -i filename
| > gives you the inode number...
| But it is often helpful to find out what are the other pathnames of the
| file/inode in question. This is possible with ncheck:
| 	ncheck -i #### /dev/xxx
|                  ...However, on some systems ncheck and/or /dev/xxx is
| protected and non-root people can't perform the above...
| 					Dan
+---------------

In that case, try:

	find / -inum #### -exec ls -l {} \;

It will show you files whose i-node numbers are "####" on ALL mounted
structures, and possibly report files which are not linked to yours,
but using the date and length reported by "ls" (or at worst looking at
each file) should disambiguate it for you.


Rob Warnock
Systems Architecture Consultant

UUCP:	{ihnp4,ucbvax!dual}!fortune!redwood!rpw3
DDD:	(415)572-2607
USPS:	510 Trinidad Lane, Foster City, CA  94404

p.s. This articele had the worst case of "time warp" I have seen in a
long time -- 9 days in the future from when "notes" touched it (five
days from my local "now"). News admins take note...

+---------------
| Relay-Version: version B 2.10.1 6/24/83; site redwood.UUCP
| Posting-Version: nyu notesfiles V1.1 4/1/84; site rna.UUCP
| Path: redwood!rhino!fortune!hpda!hplabs!hao!seismo!cmcl2!rna!dan
| From: dan@rna.UUCP
| Newsgroups: net.unix
| Subject: Re: How can I find where a link leads to
| Message-ID: <11000006@rna.UUCP>
| Date: Sun, 20-Jan-85 17:22:00 PST
| Article-I.D.: rna.11000006
| Posted: Sun Jan 20 17:22:00 1985
| Date-Received: Mon, 14-Jan-85 15:33:40 PST
| References: <719@hou2h.UUCP>
| Lines: 16
| Nf-ID: #R:hou2h:-71900:rna:11000006:000:643
| Nf-From: rna!dan    Jan 11 20:22:00 1985
+---------------

mark@elsie.UUCP (Mark J. Miller) (01/15/85)

> ... if you can run as superuser you should use "ncheck" which is lots
> faster and searches only one filesystem (thus eliminating problems 1) and 2)).
> 
Of course, you can speed up the find search by specifying the filesystem; e.g.:

	find /usr -inum <num> -print

Ncheck is MUCH faster tho.

-- 
Mark J. Miller
NIH/NCI/DCE/LEC
UUCP:	decvax!harpo!seismo!elsie!mark
Phone:	(301) 496-5688

mike@amdcad.UUCP (Mike Parker) (01/17/85)

> Granted you have found the inode number via:
> 	ls -i
> one can then use find with the -inum option to
> locate all the directory entries.
> Note that a find from / can take a veryyyyyyyy longgggggg time.
> 

Granted find is the only way to find all of the links, but
there is a special case for which there is an easier way.
If all of the links are suspected to be in one directory
( like all of the links to /bin/ex ) then I find out the inode 
number with ls -i and do an ls -i on the directory in question
with the output piped to "grep '^#'" where # is the inode number.
You can tell if you got all of the links by the link count.

Mike @ AMDCAD

keesan@bbncca.ARPA (Morris M. Keesan) (01/18/85)

--------------------

>> ... if you can run as superuser you should use "ncheck" which is lots
>> faster and searches only one filesystem (thus eliminating problems 1) and 2)).
>> 
>Of course, you can speed up the find search by specifying the filesystem; e.g.:
>
>	 find /usr -inum <num> -print
>
And of course this doesn't help as much if there are any filesystems mounted
under /usr.
-- 
			    Morris M. Keesan
			    {decvax,linus,ihnp4,wivax,wjh12,ima}!bbncca!keesan
			    keesan @ BBN-UNIX.ARPA

henry@utzoo.UUCP (Henry Spencer) (01/20/85)

> (BTW, "find -inum" is in all the version of "find" I've seen, although
> Berkeley are the only people who bothered documenting it.)

Once again, Berkeley gets credit for something they had nothing to do
with.  "find -inum" is documented in V7, Guy.  (Real V7, not x.yBSD
committing fraud by calling itself V7.)
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry

dan@rna.UUCP (01/21/85)

> ls -i filename
> gives you the inode number; otherwise the question has no meaning.
> All links have the same status; there is no place in the
> hierarchical file system where the file "really" is.

But it is often helpful to find out what are the other pathnames of the
file/inode in question. This is possible with ncheck:

	ncheck -i #### /dev/xxx

where ### is the inode number of the file you want to find all the pathnames
to and /dev/xxx is the special device name of the filesystem on which the
file/inode resides. However, on some systems ncheck and/or /dev/xxx is
protected and non-root people can't perform the above...

					Dan

mark@elsie.UUCP (Mark J. Miller) (01/23/85)

> 
> Granted find is the only way to find all of the links, but
> there is a special case for which there is an easier way.
> If all of the links are suspected to be in one directory
> ( like all of the links to /bin/ex ) then I find out the inode 
> number with ls -i and do an ls -i on the directory in question
> with the output piped to "grep '^#'" where # is the inode number.
> You can tell if you got all of the links by the link count.
> 
> Mike @ AMDCAD

Actually, you will (probably) need to use egrep and be carefull because the
ls -i call pads space characters at the begining of each line so that the
file names align. A more general way to do the deed would be:

	ls -i | awk '{ if ($1 == #) print $0}'

It would be nice if one could use "ls -iR" and search subdirectories, but
the '-R' option of ls doesn't cause the full path names to be printed.

-- 
Mark J. Miller
NIH/NCI/DCE/LEC
UUCP:	decvax!harpo!seismo!elsie!mark
Phone:	(301) 496-5688