Symlink
From Linux 101, The beginner's guide to all things Linux.
Symbolic links ("symlink") are a neat feature of Linux filesystems.
When you were in Windows, you created some file in My Documents. To make it easy on yourself to open, you may have created a "shortcut" on the desktop. That way all you had to do was double-click on your desktop icon and you got to your real file.
The basic idea is you create an entry on the filesytem to point to the real one. You did not actually copy the file itself, but you now have two possible ways to point to the same file. Your Windows shortcuts were not genuine symlinks, but they are close enough to get the concept.
[edit] Usage
Symbolic links are created with the ln command. For example:
-
ln --symbolic name_of_real_file name_of_link
-
ln -s name_of_real_file name_of_link
Most operations (open, read, write) on the symbolic link automatically dereference it and operate on its target (the real file). Some operations (e.g. removing) work on the link itself.
Using the ls command, which is standard on these systems, a symbolically linked filed might look something like this:
lrwxrwxrwx 1 jbailey jbailey 4 2003-02-07 16:49 link -> file
The 'l' in the first column is a hint that this file is a symbolic link. The information at the furthest right indicates that this file is called 'link', and that when you access it, you will see the contents of 'file'.
Symlinks can also be used to point to directories. A common example of this is under /usr/src is where you keep the Linux kernel sources. Depending on your installation, you probably have at least one kernel sources directory (such as /usr/src/linux-2.6.7/), and then you have the symlink /usr/src/linux pointing to that directory. This is a common practice because things that depend on kernel information can just always look in /usr/src/linux and they will get the kernel sources information without actually knowing which version of the kernel you are running.
In contrast with hard links, there are no restrictions on where a symbolic link can point, it can refer to a file on another file system, to itself or to a file which does not even exist (e.g. when the target of the symlink is removed). Such problems will only be detected when the link is accessed.

