|
|
This section summarizes some of the essential characteristics of symbolic links. Succeeding sections describe how symbolic links may be used, based on the characteristics outlined here.
As we have seen above,
a symbolic link is a new type of file
that represents another file.
The file to which it refers may be of any type; a regular file,
a directory, a character-special, block-special, or FIFO-special file,
or another symbolic link.
The file may be on the local system or
on a remote system.
In fact, the file to
which a symbolic link refers
does not even have to exist.
In particular, the file does not have to exist when
the symbolic link is created or when it is removed.
Creation and removal of a symbolic link follow the same rules that apply to any file. To do either, the user must have write permission in the directory that contains the symbolic link. The ownership and the access permissions (mode) of the symbolic link are ignored for all accesses of the symbolic link. It is the ownership and access permissions of the referenced file that are used.
A symbolic link cannot be opened or closed and its contents cannot be changed once it has been created.
If /usr/jan/junk is a symbolic link to the file /etc/passwd, in effect the file name /etc/passwd is substituted for junk so that when the user executes
cat /usr/jan/junkit is the contents of the file /etc/passwd that are printed.
Similarly, if /usr/jan/junk is a symbolic link to the file ../junk2, executing
cat /usr/jan/junkis the same as executing
cat /usr/jan/../junk2or
cat /usr/junk2
When a symbolic link is followed and brings a user to a different part of the file tree, we may distinguish between where the user really is (the physical path) and how the user got there (the virtual path). The behavior of /usr/bin/pwd, the shell built-in pwd, and ``..'' are all based on the physical path. In practical terms this means that there is no way for the user to retrace the path which brought the user to the current position in the file tree.
File tree with symbolic link
Consider the case shown in ``File tree with symbolic link'' where /usr/include/sys is a symbolic link to /usr/src/uts/sys. Here if a user enters
cd /usr/include/sysand then enters pwd, the result is
/usr/src/uts/sysIf the user then enters cd .. followed by pwd, the result is
/usr/src/uts