A symbolic link, aka SymLink, is a file-system object (file or directory) that points to another file system object.
The object being pointed to is called the target.
Symbolic Links#
There are three types of Symlinks supported in the NTFS file system: hard links, junctions, and symbolic links
Types of links in Windows#
| Type | Command | Files | Folders | Cross-drive |
|---|---|---|---|---|
| Symbolic Link | mklink | ✅ | ✅ (/D) | ✅ |
| Hard Link | mklink /H | ✅ | ❌ | ❌ |
| Junction | mklink /J | ❌ | ✅ | ✅ (local drives) |
Microsoft documents these options in the mklink1 command.
By default, mklink creates soft link.
And needs specific options for creating hard link and junction.
Symbolic Link#
Symbolic Links are soft links that are basically advanced shortcuts. It is a symbolic link to a local or remote file, folder, or shares path.
Symbolic links do support UNC paths (network paths that begin with \\).
When open a symbolic link, you will be redirected to the target source. Symbolic links will have a shortcut arrow icon on them.
Hard Link#
Hard Links can only be created for files. Any changes to that file are instantly visible to applications that access it through the hard links that reference it.
Hard links do not support UNC paths (network paths that begin with \\). And there will not have a shortcut arrow icon on them.
Junction#
Junctions (aka Directory Junction) are soft links that can only be created to a local folder (directory) path.
Same as hard link, junction points do not support UNC paths (network paths that begin with \\). There will have a shortcut arrow icon on junction point created.
Tips#
Deleting the hard link, symbolic link, or junction point itself will not delete anything in the target (source) folder.
But deleting anything in the link/junction or target (source) folder will delete it in both folders.
mklink [option] link targetCreating symbolic link can be helpful. For example, I can move the “C:\Users\login.ssh” directory to “D:\home\SSH”. And create a symbolic link at “C:\Users\login” pointing to “D:\home\SSH”.
Create Symbolic Link Pointing to File
mklink c:\Users\login\Desktop\cmdline.txt d:\home\cmdline.txtSymbolic Link Pointing to Directory
mklink /d c:\Users\login\.ssh \\fileserver\home\login\dotsshCreate Hard Link Pointing to File
mklink /h c:\Users\login\Desktop\cmdline.txt c:\home\cmdline.txtNote that the link and target must be on the same drive.
Create Junction Point to Directory
mklink /j c:\Users\login\.ssh d:\home\sshDifferences#
Between
mklink /dandmklink /j.Both cmdline are creating a link to a folder. The difference is
mklink /dcan support UNC. Andmklink /jcannot.Between
mklinkandmklink /h.Both cmdline care creating a link to a file. The difference in
mklink /his cannot support cross-drive file.Another difference with
mklink /his, the data still remain accessible even the original (target) file is deleted.
Symbolic link:
target.txt --> Data
link.txt --> target.txtAfter del target.txt:
target.txt --> ❌
link.txt --> ??? Broken linkHard link:
target.txt ────┐
├---> Data
hardlink.txt ──┘After del target.txt:
target.txt ❌
hardlink.txt ----> Data ✅Hard links can therefore be thought of as multiple names for the same file, rather than one file pointing at another file.


