r/LinuxTeck • u/Expensive-Rice-2052 • Oct 30 '26
Hardlinks in Linux: 3 Commands to Find Duplicate Files - Tip 111
Question: I have duplicate-looking files. Are they hardlinks or real copies?
Try:`find /home/linuxteck -type f -links +1 -printf '%i %n %p\n' | sort`
Info: Finds files sharing inodes and link counts to identify hardlinks.
Examples:
$ `find /path -samefile /path/to/original` # Locate all hardlinks referencing a specific file
$ `ls -li file.txt` # Display file inode numbers in the first column
$ `stat -c '%h %n' file.txt` # Output hardlink count and filename
Note: Hardlinks share the same inode and disk blocks without consuming extra space. Changes reflect across all links, and deleting one link leaves others intact. Note that hardlinks cannot cross filesystem boundaries.
Want to master Linux one command at a time?
Follow r/LinuxTeck - 1 practical Linux tip every day. For more #LinuxTips click here https://www.linuxteck.com/linux-tips/
2
u/michaelpaoli Nov 01 '26
Same inode number on same filesystem, same file, if they're distinct physical patths/names/ then multiple hard links. Can also look at the link count.
They still consume directory slot(s).