Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have seen in this page that inodes have a link counter to know how many files (read: "directory entry") point to this inode. Is there a way to know which directories contain such entries without traversing the whole file system? Is this information stored somewhere?

struct inode {
    kdev_t                       i_dev;
    unsigned long                i_ino;
    umode_t                      i_mode;
    nlink_t                      i_nlink;
    uid_t                        i_uid;
    gid_t                        i_gid;
share|improve this question
The fastest method - with traversal only - might be find -inum <n> -samefile path. – ott-- May 12 '13 at 17:39
@ott-- find is used with either -inum or -samefile but not with both. – Hauke Laging May 12 '13 at 18:06
@HaukeLaging you're right, only one of them. – ott-- May 12 '13 at 18:10

No. Directory entries pointing to inodes are one-way links. The inodes do not point back to the directory entries.

In order to find a complete list of directory entries that point to an inode, you need to traverse the filesystem until you have found enough directory entries to account for the inode's link count.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.