How to find the hard linked file?

How can I see whether a given file is hardlinked or not? like given a file how can I find how many files are sharing the same inode number? Thanks!
beer9Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sam_gibsonCommented:
0
sam_gibsonCommented:
Or, even better it seems...

find . -inum <inode_number>

From: http://en.wikipedia.org/wiki/Inode#Practical_considerations
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TintinCommented:
If you do

ls -l filename

the number in the 2nd column indicates the number of hardlinks the file has.

To find all the files that are hardlinked to it, do

ls -i filename

The first number is the inode.  Then do

find . -inode <inode_number> -ls
0
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

sjm_eeCommented:
Note that inode numbers are unique within a file system so you may get a file with inode number <inode number> is each mounted filesystem. Tintin's method works if your current directory is that containing the file and if your "find" have the "-inode" parammeter. For example AIX "find" needs parameter "-inum".
0
TintinCommented:
Whoops, inode was a type, I meant inum.  To prevent find searching outside the filesystem, add the -xdev flag, eg:

find . -xdev -type f -inum <inode_number> -ls
0
beer9Author Commented:
Thank you :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.