• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

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!
0
beer9
Asked:
beer9
3 Solutions
 
sam_gibsonCommented:
0
 
sam_gibsonCommented:
Or, even better it seems...

find . -inum <inode_number>

From: http://en.wikipedia.org/wiki/Inode#Practical_considerations
0
 
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
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now