Menü schliessen
Created: May 19th 2025
Last updated: May 19th 2025
Categories: IT Knowledge
Author: Elzan Ajdari

Create Junction Points and Symbolic Links with mklink – Windows vs. Linux Explained

Donation Section: Background
Monero Badge: QR-Code
Monero Badge: Logo Icon Donate with Monero Badge: Logo Text
82uymVXLkvVbB4c4JpTd1tYm1yj1cKPKR2wqmw3XF8YXKTmY7JrTriP4pVwp2EJYBnCFdXhLq4zfFA6ic7VAWCFX5wfQbCC

What is "mklink"?

On Windows systems, "mklink" is a command-line utility used to create:

  • Symbolic links

  • Hardlinks

  • Junction points

These are types of file system references that point to another location. Unlike desktop shortcuts, they function at the OS level and are fully transparent to applications.


What is a Symbolic Link (Symlink)?

A symbolic link is a reference that points to another file or folder path. When accessed, the system redirects to the actual location.

  • Works across different drives and volumes

  • Can link to files or folders

  • Becomes broken if the target is deleted or moved

Examples:

mklink Link.txt Target.txt (for files)mklink /D LinkFolder TargetFolder (for directories)

What is a Hardlink?

A hardlink creates an alternative name that points to the same file data on disk. Both the original and the hardlink are treated equally by the file system.

  • Works only for files

  • Must be on the same volume

  • Shares the same inode; deleting one does not delete the data

Example:

mklink /H Link.txt Target.txt

What is a Junction Point?

A junction point is a directory-level reference that behaves like a symbolic link but is limited to the same local volume.

  • Used for directories only

  • Does not work for files or network paths

  • Compatible with older Windows software

Example:

mklink /J LinkFolder TargetFolder

How to Use "mklink": Summary

Command Description
"mklink" Link Target Create a symbolic link to a file
"mklink /D" Link Target Create a symbolic link to a directory
"mklink /H" Link Target Create a hardlink to a file
"mklink /J" Link Target Create a junction point to a directory

Note: You must run Command Prompt as Administrator to use "mklink" successfully.


Linux Equivalent: "ln"

On Linux systems, the equivalent command is "ln". It allows you to create both hardlinks and symbolic links.

Symbolic Link in Linux:

ln -s /path/to/target /path/to/link
  • Works for files and folders

  • Can span file systems and partitions

  • Breaks if the target is moved or deleted

Hardlink in Linux:

ln /path/to/target /path/to/link
  • Works for files only

  • Must be on the same file system

  • Shares the same inode as the original


Differences Between Windows and Linux Links

Feature Windows ("mklink") Linux ("ln")
Symbolic Links /D for directories, default for files -s for symlinks (files/folders)
Hardlinks /H, files only Default ln, files only
Junction Points /J, directories only Not natively supported
Admin Rights Required Yes No
Network Path Support Only symbolic links Supported via symlinks

When to Use Each Type

  • Symbolic Links: For flexibility, especially when working across volumes or with dynamic paths

  • Hardlinks: When you need multiple references to the same file data without extra disk usage

  • Junction Points: For folder redirection on the same drive, commonly used in Windows for compatibility


Conclusion

The "mklink" utility in Windows is a powerful tool for creating different types of file system links, offering functionality similar to "ln" on Linux. Knowing the distinctions between symbolic links, hardlinks, and junction points helps you make smarter decisions when managing files, scripts, and folder structures, both in development and administration.