22. October 2011 · Comments Off on Overview to Understanding Hard links, Junction Points and Symbolic links in Windows · Categories: Windows · Tags: Shells/CLI
Last updated on 11/13/2023

Hard Links, Junction Points and Symbolic Links are linking mechanisms used to refer to other files, directories, or volumes.

file link image

Hard Link (or file hard link) – is a file that acts like a representation of another file on the same drive without actually duplicating that file.

Junction Point (or directory hard link) is a type of hard link that acts like a representation of a directory, a partition or another volume.

Symbolic Link (or soft link) is a file similar to a shortcut in that it points to a file name or directory name, but it’s handled at the system level rather than at the application level.

Often confused with shortcuts as well as with each other, Hard links, Symbolic links and Junction Points are not the same; although like shortcuts, deleting either links or junction points usually won’t delete the target and vice versa (see exceptions below). Of the three, Symbolic Links are more similar to shortcuts than either Hard links or Junction Points, and they are generally more flexible, easier to use, and safer. When given a choice, most professionals recommend using Symbolic Links.

Although Symbolic Linking has been around since 1978 and shortly thereafter standardized in UNIX and UNIX-like Operating Systems, it’s been present in Windows only since Vista. Symbolic Linking was introduced in Vista to replace Hard Links and Junction Points and to enhance compatibility with UNIX and UNIX-like systems. Hard Linking for files and support for directory hard links (Junction Points) have been present in Windows since Win2K – often using different implementations in each succeeding Windows version. Because the development of linking in Windows has been relatively recent and ongoing, a number of different linking methods have been included, supported, or made available as third-party add-ons depending on the Windows version. Currently, Hard Links, Junction Points and Symbolic Links in Windows are only supported for the NTFS file system.

Note that Windows does not support Hard Links or Junction Points to directories on remote shares; however, Symbolic Links can point to remote files and directories on SMB network paths.

The differences between Hard Links, Junction Points, Symbolic Links, and Shortcuts are further contrasted below:

Hard Link (Links individual files):

  • A file that acts like a representation of a target file on the same drive
  • Has the same size as the target without duplicating it (doesn’t use any space)
  • Interpreted at the operating system level (SW apps act upon the target through the link)
  • Deleting the Hard Link does not remove the target file
  • If the target is deleted, its content is still available through the hard link
  • Changing the contents through the Hard Link changes the target contents*
  • Must reside on the same partition as the target file
  • Compatible with Win2k and above in Windows

* Some text editors save changed text to a new file and delete the original file, which can break the link. This behavior can be changed in some editors by forcing a save over the original file instead. See discussion at Jameser’s Tech Tips here for more information.

Junction Point (Directory Hard Link):

  • A file that acts like a representation of a target directory, partition or volume on the same system
  • Has the same size as the target without duplicating it (doesn’t use any space)
  • Interpreted at the operating system level (SW apps act upon the target through the link)
  • Deleting the Junction Point does not remove the target*
  • If the target is moved, renamed or deleted, the Junction Point still exists, but points to a non-existing directory
  • Changing the contents through the Junction Point changes the target contents
  • Can reside on partitions or volumes separate from the target on the same system
  • Compatible with Win2k and above in Windows

*A Junction Point should never be removed in Win2k, Win2003 and WinXP with Explorer, the del or del /s commands, or with any utility that recursively walks directories since these will delete the target directory and all its sub-directories. Instead, use the rmdir command, the linkd utility, or fsutil (if using WinXP or above) or a third party tool to remove the junction point without affecting the target. In Vista/Win7, it’s safe to delete Junction Points with Explorer or with the rmdir and del commands.

Symbolic Link (Soft Link):

  • A file containing text interpreted by the operating system as a path to a file or directory
  • Has a file size of zero
  • Interpreted at the operating system level (SW apps act upon the target through the link)
  • Deleting the Symbolic Link does not remove the target
  • If the target is moved, renamed or deleted, the link still exists, but points to a non-existing file or directory
  • Points to, rather than represents, the target using relative paths
  • Can reside on partitions or volumes separate from the target or on remote SMB network paths
  • Compatible with UNIX and UNIX-like systems and with Vista and above in Windows

Shortcut:

  • A file interpreted by the Windows shell or other apps that understand them as paths to a file or directory
  • File size corresponds to the binary information it contains
  • Treated as ordinary files by the operating system and by SW programs that don’t understand them
  • Deleting the shortcut does not remove the target
  • Maintains references to target even if the target is moved or renamed, but is useless if the target is deleted
  • Points to, rather than represents, the target
  • Can reside on partitions or volumes separate from the target on the same System
  • Compatible with all Windows versions

Windows Applications for Creating Links:

A number of applications are available for creating links in Windows including those bundled with the operating system and third-party tools. Some of the more well known are summarized below.

Utilities included with Windows:

  • fsutil – a command line tool included with WinXP and above. It can only create Hard Links for files – it doesn’t create directory hard links (Junction Points) or Symbolic Links. Further information about this tool is available at Commandwindows.com.

usage: FSUTIL hardlink create new_filename existing_filename

  • mklink – a command line tool included with Vista and Server 2008 and above. The most current link creation tool included with Windows. It creates Hard Links, Symbolic Links and Junction Points.

usage: mklink [[/d] | [/h] | [/j]] <NameofLink> <Target>

/d – Creates a Symbolic Link for a directory. If no flag used, creates a Symbolic Link for a file (default)

/h – Creates a Hard Link

/j – Creates a Junction Point

<NameofLink> – The name for the Symbolic Link being created

<Target> – The relative or absolute path of the target

/? – Help

Third-party Tools:

Command line tools:

  • junction.exe – by Sysinternals  – Creates Junction Points and includes additional commands for displaying and deleting them. Runs on Windows XP and higher and Windows Server 2003 and higher.

display reparse point* info usage: junction.exe [-s] [-q] <file or directory>

-q – Don’t print error messages (quiet)

-s – Recurse subdirectories

create usage: junction.exe <junction directory> <junction target>

delete usage: junction.exe -d <junction directory>

*Reparse points are redirections in the Windows file system using user-defined data in tags to identify and process files.

  • linkd.exe – Part of the Windows 2003 Resource Kit  – Creates and deletes Junction Points. (For Win2k, WinXP and Windows Server 2003)

create usage: linkd newdirname existingdirname

delete usage: linkd newdirname /D

Context Menu/Shell tools:

  • Link Shell Extension (LSE)http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html – Creates Hard Links, Junctions, Volume Mountpoints, and Symbolic Links with the right mouse button. LSE works on all Windows versions supporting NTFS ver 5.0 or later, including Windows XP32/64 and Windows7. To install LSE on XP, see this section from the above article.Note: LSE was tested on a XP32 system to create Symlinks with the context menu and with the command-line executable (ln.exe). The ln command is a standard Unix command that creates a hard link or a symbolic link. To delete Symlink directories, use the rmdir command.
  • NTFS Linkelsdoerfer.name – Creates Hard Links and Junction Points using drag and drop with the right mouse button. Works with Win2K (NTFS ver 5 or greater) and above.

GUI-based tools:

  • Junction Link Magic – Rekenwonder Software – GUI-based application to create, list, and remove Junction Points. Also lists Symbolic Links and Mount Points. Works with Win2K, XP, 2003, Vista, Windows Server 2008 and Windows 7. Junction Link Magic lists all 3 types of links, but only creates and removes junction links.

Combination GUI/Command Line/Context Menu/Shell tools:

  • LinkMaker Cresstone.com appsPortable and easy-to-use application featuring three modes: (1) GUI, (2) shell integration, or (3) command line. Creates shortcuts, symbolic links and NTFS hardlinks/junction points. Requires NET 4.0 or above. GUI capable of drag and drop. Works with Win XP and above.

Tutorials on creating and using Hard Links, Soft Links and Junction Points:

Daniel Einspanjer’s journal How To Use Hardlinks And Junctions In Windows

The Developer’s TidbitWindows File Junctions, Symbolic Links and Hard Links

How-to GeekUsing Symlinks in Windows Vista

Jameser’s Tech TipsTip #37: Creating NTFS Hard Links in Windows XP

Jeff Wouters’s BlogMaking soft and symbolic links in Windows

Maxi-PediaMklink in Windows

Maxi-Pedia –  Difference between symbolic link and hard link

 

If you have found a spelling error, please, notify us by selecting that text and pressing Ctrl+Enter.

Print Friendly, PDF & Email
Share
search
">Bear

Bad Behavior has blocked 1839 access attempts in the last 7 days.

Spelling error report

The following text will be sent to our editors:

support