Mklink in Windows

Mklink in Windows



Mklink is a MS Windows command line utility that you can use to create symbolic links or symlinks and hard links in MS Windows. Mklink is a nice tool for troubleshooting file system problems. Mklink requires administrative privileges.

This page relates to explaining the difference between symbolic links and hard links on the Difference between symbolic link and hard link page.

First, let's introduce the mklink command. You can see it in the following print screen:

Mklink

It is pretty self-explanatory. Now, let's take a look at an example.

Mklink example

The print screen shown below demonstrates creating symbolic links, hard links, and shortcuts in MS Windows and how they differ.

Symbolic link:

  • Created as mklink link_name target_name
  • The icon next to the link is the same like that of a shortcut
  • Occupies zero space in the system
  • It is not a separate file in the file system
  • Interpreted at the operating system level
  • If the original file is deleted, the link is useless
  • Removing the original file does not remove the symbolic link
  • Removing the symbolic link does not remove the original file

Hard link:

  • Created as mklink /H link_name target_name
  • The space it occupies equals the size of the original file, but refers to the same object in the system (not a copy)
  • Interpreted at the operating system level
  • The icon next to the hard link is different from the other objects
  • Removing the original file does not remove the hard link
  • Removing the hard link does not remove the original file
  • If the original file is deleted, its content is still available through the hard link
  • Making a change to the hard link propagates all changes to the original file

Shortcut:

  • Created by right clicking the original file and selecting action from the drop down menu
  • A file in the system that is completely separate from the original file
  • Only those programs that know the concept of shortcuts understand them
  • If the original file is deleted, the link is useless
  • Removing the original file does not remove the shortcut
  • Removing the shortcut does not remove the original file

The print screen below shows these concepts. 

Mklink to create hard links and symbolic links

Linux uses a similar command called ln.

Mklink in Windows versus Ln in Linux 

Note, the mklink syntax is a bit different from the Linux ln syntax (ln is used in Linux to create links).

Mklink: The name of the link is followed by the name of the target in the mklink command syntax. If you do not specify any flag, the mklink utility creates a symbolic link by default.

Ln: The name of the target is followed by the name of the link. If you want to create a symlink, you have to specifically include the -s flag.

.

Discuss this article or this topic in our discussion forum:
(The table bellow shows a list of 8 most recent topics posted in our discussion forum. Visit our discussion forum to see more. It is possible the links below are not related to this page, but you can be certain you will find related posts in the discussion forum. You can post one yourself too.)
Email this article to a friend:
TO: 
FROM: 
2 + 6 - 3 = 
.
How can I link to this web page?

It is easy, just include the code provided below into your HTML code.

<a href="http://www.maxi-pedia.com/mklink" title="www.Maxi-Pedia.com: Mklink in Windows" target="_blank">Mklink in Windows</a>
.