Go to the first, previous, next, last section, table of contents.


How to locate the other (hard) links to a file.

Let's say that I notice that the file referenced by the file name `quux' has more than one link:

$ ls -li quux
  33059 -rw-r--r--   2 reiter   staff      172340 Jun 30 17:08 quux

To find the other links (names) of a file, you need to know the file's inode number, and in general also its filesystem (or rather the mount point of that filesystem).

You can see the inode number when you give the `-i' (or `--inode') option to ls. In the above example (`ls -li'), it's the left-most field, 33059.

To find what filesystem a file belongs to, do `df file'. The mount-point of this filesystem is the last field, under the heading `Mounted on'. So in our example:

$ df quux
Filesystem         1024-blocks  Used Available Capacity Mounted on
/dev/hda2             149806  123118    18952     87%   /home

so the relevant mount point is `/home'.

Putting it all together, the general command is find mountpoint -xdev -inum inum (optionally --or necessarily, if you don't use GNU find-- followed by `-ls', `-print' or some such). To continue our above example:

$ find /home -xdev -inum 33059 -ls
  33059  169 -rw-r--r--   2 reiter   staff      172340 Jun 30 17:08 /home/gonzo/grault
  33059  169 -rw-r--r--   2 reiter   staff      172340 Jun 30 17:08 /home/reiter/corge/quux


Go to the first, previous, next, last section, table of contents.