logo
Windows 10 How to Use Window 10 mklink Command [Tutorials]

How to Use Window 10 mklink Command [Tutorials]

By Achilles Hill | Last Updated

If you are interested in how to use mklink command on Windows 10, follow this article which will show you what is the mklink command and list four usages of the mlink command.

how to use Windows 10 mklink command tutorial

Part 1: What is mklink Command?

The mklink command is a command that comes with Windows, and it can be used in Win 10, as well as in earlier systems such as Win 7, Win Vista, Win 8, and Win 8.1. However, if you use it on systems other than Win 10, you must have administrator privileges, or you will be prompted with "You do not have sufficient privileges to perform this operation". Of course, Windows 10 sometimes requires administrator privileges as well.

Open the command prompt, type mklink /? on the Command Prompt window, then press Enter. The system lists the usage of the mklink command.

type mklink on the command prompt

Part 2: How to Use mklink Command?

For the ease of my example, I created two folders on my D drive under the Simple folder: the Link folder, and the Target folder.

create link and target

1. Create a file symbolic link

Nothing with parameters is the default creation of file symbolic links. The use of this command requires administrator privileges, so you must run the command prompt as administrator.
Type the following command and press Enter: mklink d:\Simple\Link\text.txt d:\Simple\Target\text.txt.

create file symbolic link

At this point, we open the Link folder and we see a shortcut-like file appear below:

shortcut text appear

But this text.txt is not a shortcut, it's a symbolic link, we can open and use it normally under the Link folder, but the file is stored under the Target folder. This is just like having two identical files in two different folders, and editing any one of them will change both of them at the same time.

2. Create a directory symbolic link

Also, this one is a command line that requires administrator privileges. Type the following command and press Enter: mklink /d d:\Simple\Link\Target d:\Simple\Target.

create directory symbolic link

At this point, we will notice an additional Target folder under the Link folder:

additional target folder

This is not a shortcut, it is a virtual folder. Open the new Target folder, you will find that and the real storage location of this folder is d:\Simple\Target, so you can also store files in the Link\Target directory without taking up space in this folder.

open target folder

3. Create a directory junction

This command requires to use of the /j parameter and is very similar to the second command, but this command does not require administrator privileges.
Type the following command and press Enter: mklink /j d:\simple\link\new d:\simple\target.

create directory junction

A new folder with a shortcut corner appears under the Link folder:

a new folder

Then we open the new folder and find that the storage path in the properties is the same, as if the new folder exists here, which is not the same as /d. The new folder is still stored in the original d:\simple\target location.

open new folder

4. Create a hard link

The three commands above still have the shortcut corner markers, and you'll notice a difference in the results of the following command.
The hard link still doesn't require administrator privileges, just type in the command with the /H parameter and press enter: mklink /h d:\Simple\Link\new.txt d:\Simple\Target\text.txt.

create hard link

Then a new.txt will appear in the Link folder without a shortcut corner, and it looks like a file.

a new text appear

If you modify new.txt, you will find that the contents of the original text.txt will be changed at the same time.

Final Words

I believe you should understand how to use the mklink command by my example. This command is still very useful, we can "virtualize" files or folders to other directories. Especially when there is not enough space on the C drive, you can "virtualize" a file or folder on the path corresponding to the C drive, so that you can move some folders or files that are stored on the C drive by default to a partition with more space such as D drive.

However, it should be noted that not all folders on C drive can be handled in this way, especially system folders, which are sometimes prone to errors and must be used with caution!

Related Articles: