GeekPolice Tech TutorialsLog in

 


What is a Symbolic Link in Windows?

Share

20180117
What is a Symbolic Link in Windows?

What is a Symbolic Link in Windows?

Windows 10, 8, 7, and Vista all support symbolic link (also symlink or soft link) that point to a file or folder on your system. Symbolic links are basically advanced shortcuts. Symbolic links are transparent to users; the links appear as normal files or directories, and can be acted upon by the user or application in exactly the same manner.


For example, If you have a program that needs its files at C:\Program. You’d really like to store this directory at D:\Stuff, but the program requires that its files be at C:\Program. You could move the original directory from C:\Program to D:\Stuff, and then create a symbolic link at C:\Program pointing to D:\Stuff. When you relaunch the program, it will try to access its directory at C:\Program. Windows will automatically redirect it to D:\Stuff, and everything will just work as if it were in C:\Program.

Windows processes symbolic links on the local system, even when they reference a location on a remote file server.

There are three types of symlinks: soft symbolic links, work similarly to a standard shortcut. When you open a soft link to a folder, you will be redirected to the folder where the files are stored. Hard links, makes it appear as though the file actually exists at the location of the symbolic link, and your applications won’t know any better.  Third link type is Junction, basically a hard link but as hard links can only link files we need to use junctions to link folders.

You can create a symbolic link from a Command Prompt with the Mklink command.


How to Create Symbolic Links with Mklink

Open the Command Prompt by clicking Start Menu --> All Programs --> Accessories, right-click on Command Prompt, and open it as an administrator. In Windows 8, 8.1 and Windows 10 type cmd.exe into Start Screen or Start Menu, right-click on Cmd.exe, and open it as an administrator.



The default command (without any options) will create a soft symbolic link to a file. For example, below command:


Code:

mklink pad.exe notepad.exe



Will create a soft symbolic link called pad.exe to the notepad.exe.

Using the /D option will create a symbolic link to a folder.

The below command creates soft symbolic link called "Docs" from the root director to the \Users\FreeBoter\Documents directory.


Code:

mklink  /d  \Docs  \Users\FreeBoter\Documents



The /H option will create a hard link to a file.


Code:

mklink /h pad.exe notepad.exe



Finally, the /J option will create a hard link to a folder. This is also called a Directory Junction (a.k.a. junction point) and instead of working like a shortcut to a folder, a hard link works more like a regular folder. For example, the command:


Code:

mklink /J  c:\one  c:\two\three\four



Makes the operating system work with the long directory structure c:\two\three\four just as if it were a single directory named c:\one.

You can terminate the link simply by deleting the link.
 
remove_circleSimilar topics

Comments

No Comment.
Permissions in this forum:
You cannot reply to topics in this forum