Describes the process of creating a hard link to file, and searching for hard links for any given file.
To create a hard link it’s easy just write
ln <target> <destination>
Because they are not symbolic links they won’t show up as links when you do
So to find which files have links, you can do the following
find -type f -links +1
This will give you which files are hard linked, but will not tell you to which files they are hard linked too.
To find the which files are linked to which files you can use inodes, to find the inode of a file you simply can use the command stat.
This will give you an output similar to this one.
File: `/tmp/tmp.file' Size: 122880 Blocks: 240 IO Block: 4096 file Device: 815h/2069d Inode: 1441793 Links: 20 Access: (1777/drwxrwxrwt) Uid: (0/root) Gid: (0/root) Access: 2013-03-18 01:04:18.182327478 +0900 Modify: 2013-04-21 13:48:14.227089591 +0900 Change: 2013-04-21 13:48:14.227089591 +0900 Birth: -
The inode number is there so now you can just search for that inode
ls -iR / | grep <inode_number>
Another way to find the files linked is to use this command but only if you know the file you want search for.
find / -samefile <full_path_to_filename>