hard links
A hard link is one file which exists in multiple locations.
Each file has an ID, which is kept on the hard disk's partition. Each hard link has the same ID, because they are the same file. This ID is called the 'inode'.
Create a file, and a hard link:
Have a long look at the file with the -l
flag, and check the inode with -i
:
Since they are the same file, you can make a change to one, and it changes both:
Danger Zone
- hard links will not work on directories, only standard files and fifos.
git
will destroy and remake files, so it will not respect hard links.- Files cannot have a hard link on another disk partition, because the inode is stored on each partition.