On unix file systems every filename is actually a hard link to the location of the data on the disc, called an inode. If you create a new hard link to an existing file, it will take no extra space on the disk as it is just another pointer to the same data. If you edit the data by one or other link (or edit the inode directly) both files will be changed.
The system keeps a count of how many hard links each inode has. When the link count is 0, the file can no longer be reached, and the data is marked as safe to be overwritten. So given a file with 2 hard links, if you delete either link, the data will not be deleted. Only if you delete both will the data be gone.
You can see the inode numbers of files using the -i
switch to the ls
command.
A soft link, on the other hand, points to another file by its file name. If you move or delete the original file, the link will be broken.