4.0 Linking files and directories


1. When Unix creates a file it, (1) sets aside space on the hard disk to
store the data that is in the file and (2) creates a structure called an
inode (index node) to hold the basic information about the file. Each
inode is associated with an inode number. We use the option ls -li to
see the inode numbers associated with existing files and subdirectories.

Commands to learn:

ln (1)			- make hard or symbolic links to files

2. Note that directory tables only contain the name of the file and the
inode number associated with that file name.

3. A (hard) link to a file name is a "nickname" or alias for that file name. 
It has the same inode number as the original name. Use ls -li to show
the number of hard links to a file as well as its inode number.  All links
are treated the same. There is no concept of an orginal or master file.

4. To make a new (hard) link to a file in the current directory, use the 
link command:
	ln "existing filename" "newname"

5. To make a new (hard) link to one or more files in another directory, keeping 
the same names, use:
	ln "existing filenames" "existing directory"

6. To create a new (soft or symbolic) link to a file, use the link command:
	ln -s "existing file" "newname"

7. Use ls -l to show the result: e.g.

$ cd /bin
$ ln -s /bin/csh tcsh; ls -l /bin/csh
lrwxrwxrwx    1 root     root            4 Dec 21  2000 /bin/csh -> tcsh

Questions? Robert Katz: rkatz@ned.highline.edu
Last Update July 16, 2002