Finding out the file name associated with an inode


While perusing the logfiles on one of my personal systems a while back, I noticed that an error was generated with the inode of a troublesome file (I can’t recall the specifics). Since the error was rather vague and contained an inode number, I wanted to resolve the inode number to a file name to see which file was making the application angry. There are NUMEROUS way to resolve inode numbers to file names, but my favorite methods involve find and ncheck. To use find to locate the file name associated with an inode, you can pass the inode number to find’s “-inum” option:

$ find /export/home -inum 12345 -ls

If find doesn’t fit your fancy, you can also use the ncheck utility to resolve a file name to an inode:

$ ncheck -i 261

/dev/dsk/c0t0d0s0:
261 /usr/bin/cktime
261 /usr/sadm/bin/errtime
261 /usr/sadm/bin/helptime
261 /usr/sadm/bin/valtime

The find command tends to run significantly faster, but ncheck can be a viable alternative in some cases.

This article was posted by Matty on 2006-03-13 11:30:00 -0400 -0400