Link

A link is a named connection between a directory and an object. A user or a program can tell the server where to find an object by specifying the name of a link to the object. A link can be used as a path name or as part of a path name.

For users of directory-based file systems, it is convenient to think of an object, such as a file, as something that has a name that identifies it to the server. In fact, it is the directory path to the object that identifies it. You can sometimes access an object by giving just the object's "name". You can do this only because the system is designed to assume the directory part of the path under certain conditions. The idea of a link takes advantage of the reality that it is the directory path that identifies the object. The name is given to the link rather than the object.

After you get used to the idea that the link has the name rather than the object, you begin to see possibilities that were hidden before. There can be multiple links to the same object. For example, two users can share a file by having a link from each user's home directory to the file (see Home directory). Certain types of links can cross file systems, and can exist without an object existing.

There are two types of links: Hard link and Symbolic link. When using path names in programs, you have a choice of using a hard link or a symbolic link. Each type of link has advantages and disadvantages. The conditions under which one type of link has an advantage over the other type is as follows:

Table 1. Comparison of hard link and symbolic link
Item Hard link Symbolic link
Name resolution Faster. A hard link contains a direct reference to the object. Slower. A symbolic link contains a path name to the object, which must be resolved to find the object.
Object existence Required. An object must exist in order to create a hard link to it. Optional. A symbolic link can be created when the object it refers to does not exist.
Object deletion Restricted. All hard links to an object must be unlinked (removed) to delete the object. Unrestricted. An object can be deleted even if there are symbolic links referring to it.
Static objects (attributes do not change) Faster. For a static object, name resolution is the primary performance concern. Name resolution is faster when hard links are used. Slower. Name resolution is slower when symbolic links are used.
Scope Restricted. Hard links cannot cross file systems. Unrestricted. Symbolic links can cross file systems.
Related reference
Links in the "root" (/) file system
Links in the QOpenSys file system
Links in an integrated file system user-defined file system
Links in the QSYS.LIB file system
Links in the independent ASP QSYS.LIB file system
Links in the QDLS file system
Links in the QOPT file system
Links in the QNTC file system
Links in the QFileSvr.400 file system
Links in the Network File System
Tips: Symbolic link
Links in the QNetWare file system