Symbolic links, Hard Links, Soft Links, Junctions - What They Are
File and directory aliases can be very useful. Several types called hard links, symbolic links (symlinks), and junctions are available in Windows 7. They are described and their uses explained.
It is very common for operating systems to have a way of creating aliases for files and directories. For example, Unix and its numerous progeny and relatives provide for aliases called "hard links" and "soft links". On the other hand, Windows with FAT16 and FAT32 file systems made no use of this type of feature. Some provision was made in the NTFS file system in Windows 2000 and beginning with Windows Vista, several types of aliases are available that provide useful functions - hard links, symbolic (soft) links, and junctions (introduced in Windows 2000). In some ways, these aliases resemble the well-known shortcut file but there are fundamental differences.
In this article I will describe the various kinds of links; a companion article explains how they are created and how they are used.
How hard links and symbolic links differ from conventional shortcut files
First, let's try to clarify what a traditional shortcut is. It is an actual file with various standard file properties and an extension lnk. (The extension is usually hidden.) It also contains a reference to an object like a folder or another file and has the special property that the Windows shell knows that double-clicking it should open the object that is referenced in the file. However, applications will generally operate on the shortcut file itself and not on the object that the shortcut file references.
For example, if you have a shortcut to a text file and try to open the shortcut directly with Notepad, it will try to read the contents of the shortcut file, not the referenced text file.
Programmers often use the term "transparent" to indicate if applications can act as if the link were actually the referenced file or folder. Standard Windows shortcut files are not transparent but hard links and symbolic links are.
A glossary of terms
The Microsoft documentation on Windows symbolic links, junctions, and related subjects is inconsistent. Also, I find articles and various descriptions of this subject on the web to be confusing and often contradictory. Here are the meanings of various terms as I understand them after digging through the MSDN documentation (no models of clarity). These apply to Windows and may be somewhat different for Unix and its relatives.
- Symbolic link or symlink
- This was introduced beginning with Windows Vista and is sometimes equated to a "soft link". A Windows Vista/7/8 symbolic link is defined by Microsoft as "a file-system object that points to another file system object". It can refer to files or folders (directories) or even to remote shares . However, the reference is just to a name and not directly to a file object. A symbolic link contains a text string that is interpreted by the operating system as a path to another file or directory called the target. If the target is moved, renamed, or deleted, the symbolic link remains but leads nowhere. It is then said to be "broken". Unlike shortcut files, symbolic links are transparent to most applications. However, important exceptions to transparency are certain backup programs.
- Hard link
- A hard link is not a file itself but an additional address or alias for a file. It allows a file to be accessed from several locations. Addresses must all be on the same volume. In Windows, only files can have hard links. Only one copy of the file will actually exist but it will appear to be located in several places. File edits made at any address appear at all addresses. Deletion of a hard link only removes the address and not the file as long as at least one address remains.
- Soft link
- Used in several different senses. Often equated to "symbolic link" but sometimes equated to "junction" or to both. There seems to be some confusion in various places because what Microsoft calls a soft link is a file object and in many Unix-type systems, a soft link is a lower level entry in the file system.
- Junction points were introduced in Windows 2000.They use "reparse points" and are an older way of linking local directories. They are sometimes erroneously called hard links, even by supposed experts. A junction is, in fact, a soft link with path information about a target directory. Although superseded in some respects by Microsoft's version of symbolic links, junctions are used in Windows Vista/7 to redirect certain system folders from their old Windows XP names to new names. For example, "My Documents" gets redirected to "Documents". Junctions are limited to linking local directories but they can be on separate volumes.
- Reparse point
- A collection of user-defined data contained in a file or directory. When the file system opens a file with a reparse point, the file is processed as directed by the reparse data and an associated file system filter. Used for folder redirection and for mounting folders.
Creation and Use of Hard Links, Symbolic Links, and Junctions
Windows 7 has several command-line tools for creating hard and soft links. The creation and use of these handy links is described on the following page.