Quick Linux 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.
Leave a Reply