DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Application programming

Symbolic links

A symbolic link is a special type of file that represents another file. The data in a symbolic link consists of the path name of a file or directory to which the symbolic link file refers. The link that is formed is called symbolic to distinguish it from a regular (also called a hard) link. A symbolic link differs functionally from a regular link in three major ways.

When a user creates a regular link to a file, a new directory entry is created containing a new filename and the inode number of an existing file. The link count of the file is incremented.

In contrast, when a user creates a symbolic link (using the ln(C) command with the -s option), both a new directory entry and a new inode are created. A data block is allocated to contain the path name of the file to which the symbolic link refers. The link count of the referenced file is not incremented.

Symbolic links can be used to solve a variety of common problems. For example, it frequently happens that a disk partition (such as root) runs out of disk space. With symbolic links, an administrator can create a link from a directory on that file system to a directory on another file system. Such a link provides extra disk space and is, in most cases, transparent to both users and programs.

Symbolic links can also help deal with the built-in path names that appear in the code of many commands. Changing the path names would require changing the programs and recompiling them. With symbolic links, the path names can effectively be changed by making the original files symbolic links that point to new files.

In a shared resource environment like NFS, symbolic links can be very useful. For example, if it is important to have a single copy of certain administrative files, symbolic links can be used to help share them. Symbolic links can also be used to share resources selectively. Suppose a system administrator wants to do a remote mount of a directory that contains sharable devices. These devices must be in /dev on the client system, but this system has devices of its own so the administrator does not want to mount the directory onto /dev. Rather than do this, the administrator can mount the directory at a location other than /dev and then use symbolic links in the /dev directory to refer to these remote devices. (This is similar to the problem of built-in path names since it is normally assumed that devices reside in the /dev directory.)

Finally, symbolic links can be valuable within the context of the virtual file system (VFS) architecture. With VFS, new services, such as higher performance files and network IPC, may be provided on a file system basis. Symbolic links can be used to link these services to home directories or to places that make more sense to the application or user. Thus, you might create a data base index file in a RAM-based file system type and symbolically link it to the place where the data base server expects it and manages it.

Where to find more information

``Directory and file management'' discusses symbolic links in detail. Refer to symlink(S) for information on creating symbolic links. See also stat(S), rename(S), link(S), readlink(S), unlink(S), and ln(C).


Previous topic: Where to find more information

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005