ln - Links, Links, Links

One of the things that makes the UNIX filesystem so flexible is the idea of links. There are two types of links: hard links, which we wont discuss here, and symbolic links.

The syntax to create a symbolic link is:

ln -s real_file link_name
So, for example, if you have this file:
-rwx------  1 roth     student       175 Dec  8 23:03 .xsession*
If you want to create a link called .xinitrc which points to it, use this:
tcsh> ln -s .xsession .xinitrc
An ls -laF of a symbolic link looks like this:
lrwxrwxrwx  1 roth     student      9 May  8  1995 .xinitrc -> .xsession*
You can tell it's a link because of the l in the first field of the permission bits.

Most operations performed on the file .xinitrc will instead be performed on the file that the link points to; in this case, .xsession. rm will remove the link, but not the file it points to, and mv will move or rename the link instead of the file it points to. However, chmod will change the permissions on the file pointed to, instead of the link itself.


Mark D. Roth (roth@uiuc.edu)