[file name] [i-node number]
meaning that all the information about the file referenced by file name is contained in the entry for i-node number in the i-node table.
touch spon - to create a new file "spon" ln spon spon_toowill create two names for the same file. Note that "spon" and "spon_too" are on an equal sponting. They are both "hard links": "spon_too" is in no way inferior to "spon".
The i-node entry for a file contains a field that stores the number of links made to that file. If you continue the previous example with
ll -i spon*
then you will see that the file names refer to the same i-node entry (1st column) and the 3rd column shows that this file has 2 links to it (namely "spon" and "spon_too").
1673 -rw------- 2 xyz99 ugrad 0 Oct 12 02:21 spon 1673 -rw------- 2 xyz99 ugrad 0 Oct 12 02:21 spon_tooA file doesn't disappear until all the hard links to it have been removed, so doing
will not remove the file that "spon" referred to, only this link to it.
Note also that you can't hard link between file systems ; each file system has its own i-node table so an i-node index is not unique across file systems.
ln -s spon spon_too
you will see that "spon" and "spon_too" no longer reference the same i-node.
A symbolic link is a (sort of) string alias; wherever you mention "spon_too" it will be substituted for by "spon". "spon" and "spon_too" no longer have the same status; if you do:
you will only remove the alias whereas if instead you do:
you will remove the file that "spon" referred to, and "spon_too" will be left pointing to a nonexistant file.
To see if an entry in a directory is a symbolic link or not, type:
If an "l" appears in the 1st column, then the file is a symbolic link, the size is the size of the link and the last column shows where the link points.
-rw------- 1 xyz99 ugrad 0 Oct 12 02:39 spon lrwx------ 1 xyz99 ugrad 4 Oct 12 02:39 spon_too -> sponIf you do:
you will be given information about the file that the symbolic link points to rather than the link itself.
A number of programs distinguish between hard and symbolic links. For example, tar has an option (-h) which saves files that links point to rather than the links themselves.
Symbolic links, unlike hard, can be made between file systems and can refer to directories; this is their main use.
cd .. can have unexpected (but predictable) results with symbolic links.
To find the symbolic links recursively under a directory, use:
find directory-name -type l -print
To find all the mount points on the root directory, use:
find / -type M -print
1) ln(1) - use man ln: note that the syntax of this is
ln [options] file_linked_to name_of_link
The arguments are this way round so that the final argument can default to the last component (the basename) of the file_linked_to.
2) The fields of i-node entries are in /usr/include/sys/inode.h.
Updated on 9th October 1997