- How to Create Symbolic Links (Symlink) in Windows 10
- What Are Symbolic Links?
- Create Symbolic Link Using Link Shell Extension
- Create Symbolic Link Using Mklink
- Symlinks in Windows 10!
- Overview
- Background
- What drove this change?
- How to use Symlinks
- How do I try it?
- Symbolic Links – Create Folder / Directory Alias in Windows How to create true directory aliases in Windows (not shortcuts) using Symbolic Links with mklink, Powershell or Junction (Sysinternals)
- Introduction
- Shortcut vs Simbolic Links
- Shortcuts
- Symbolic Links
How to Create Symbolic Links (Symlink) in Windows 10
Symlinks or Symbolic Links is one of the lesser known, yet useful, features in Windows. You can think of symbolic links as the shortcuts you create in Windows. However, symbolic links are much more powerful and helpful than regular shortcuts. Let’s discuss what symbolic links are and how you can easily create them in Windows 10.
What Are Symbolic Links?
When you create a shortcut for a file or folder, all you are doing is pointing it to that specific file or folder, nothing more. Symbolic links are much more than a simple shortcut. They act as a virtual file or folder that links to the actual file or folder.
When you create a symlink for a file, it appears as if it is the actual file when in reality it is redirecting you toward the real file in the background. Besides files, you can also create symlinks for folders. Simply put, a symlink is nothing more than a build of the text string which lets the operating system know that it is just a path for another file or folder.
For instance, most cloud service apps you install will only sync files and folders located in their own folder. But there will be times when you might have a folder in some other drive you want to sync with the cloud storage service.
However, you don’t want to move the folder from its actual location or don’t want to create a copy of the folder. In those situations you can simply create a symlink in the cloud service folder so that you can sync the contents of the target folder without actually moving or copying the real folder.
Since a symlink is just a virtual folder that just acts as a path to the real folder, you don’t have to worry about the symlink consuming your disk space.
Create Symbolic Link Using Link Shell Extension
If you don’t want to faff around in the Command Prompt and are prepared to faff around a little bit by installing a tool that lets you create symlinks to an existing file or directory using the right-click context menu, then try the following. Link Shell Extension is a tool that lets you create hardlinks and symbolic links by right-clicking whatever folder you want to create a link to.
There are a few hoops with the installation. You’ll get a warning that it can’t be downloaded securely, and Windows Defender may warn you that it’s “unsigned.”
We can assure you that the tool is safe. Go ahead and install it. During installation, explorer.exe will restart, so make sure you have important stuff backed up.
Once LSE is installed, right-click the target file or folder you want to create a symlink to, then click “Pick Link Source.”
Next, go to the folder where you want the symlink to appear, right-click it, then select “Drop As -> Symbolic Link.”
Create Symbolic Link Using Mklink
Note: though I’m showing this in Windows 10, the commands shown here are applicable to Windows Vista and up.
Creating symlinks in Windows is pretty easy with the mklink command. To start, press Win + X , then select the option “Command Prompt (Admin)” to open the Command Prompt with admin rights.
Once the command prompt has been opened, use the below command format to create a symlink for a file.
In my case, I want to create a symlink in the E drive for a text file located on the F drive, so the command looks something like this:
The first path you see in the above command is where you will create your symlink. This path is called a “Link.” The second path belongs to the actual file on your disk and is called “Target.”
Once the symlink has been created, this is how it looks in the File Explorer. Though the icon looks like a regular shortcut, it is a symlink.
Along with individual files, you can create symlinks for entire directories. To do that, use the below command. The switch /D allows you to do this.
As soon as you execute the command, the symlink will be created for the target directory. You can use it to access all the files and folders inside the real folder. If you ever want to, you can delete the symbolic link like any other file or folder. Just select the symlink, press the delete key on your keyboard, and you are good to go.
And you’re done! If you want to do more under-the-hood tweaking in Windows 10, see our list of the best registry hacks. Also, check out our guide on how to get Mac-style hot corners in Windows 10.
Symlinks in Windows 10!
Overview
Symlinks, or symbolic links, are “virtual” files or folders which reference a physical file or folder located elsewhere, and are an important feature built in to many operating systems, including Linux and Windows.
The Windows’ NTFS file system has supported symlinks since Windows Vista. However, it hasn’t been easy for Windows developers to create symlinks. In our efforts to continually improve the Windows Developer experience we’re fixing this!
Starting with Windows 10 Insiders build 14972, symlinks can be created without needing to elevate the console as administrator. This will allow developers, tools and projects, that previously struggled to work effectively on Windows due to symlink issues, to behave just as efficiently and reliably as they do on Linux or OSX.
Background
A symlink is essentially a pointer to a file or folder located elsewhere, consumes little space and is very fast to create (compared to copying a file and its contents).
Because of this, developers often replace duplicate copies of shared files/folders with symlinks referencing physical files/folders. Replacing redundant copies of files can save a great deal of physical disk space, and significantly reduce the time taken to copy/backup/deploy/clone projects.
In UNIX-compatible operating systems like Linux, FreeBSD, OSX, etc., symlinks can be created without restrictions.
However, for Windows users, due to Windows Vista’s security requirements, users needed local admin rights and, importantly, had to run mklink in a command-line console elevated as administrator to create/modify symlinks. This latter restriction resulted in symlinks being infrequently used by most Windows developers, and caused many modern cross-platform development tools to work less efficiently and reliably on Windows.
Now in Windows 10 Creators Update, a user (with admin rights) can first enable Developer Mode, and then any user on the machine can run the mklink command without elevating a command-line console.
What drove this change?
The availability and use of symlinks is a big deal to modern developers:
Many popular development tools like git and package managers like npm recognize and persist symlinks when creating repos or packages, respectively. When those repos or packages are then restored elsewhere, the symlinks are also restored, ensuring disk space (and the user’s time) isn’t wasted.
Git, for example, along with sites like GitHub, has become the main go-to-source code management tool used by most developers today.
Figure 1: SCM Tool Trends 2004-2016 (Source, Google)
The use of package managers in modern development has also exploded in recent years. For example, node package manager (npm) served
400 million installs in the week of July 1 st 2015, but served more than 1.2 billion installs just one year later – a 3x increase in just one year! In late June 2016, npm served more than 1.7 billion node packages in just seven days!
Figure 2: npm served 1.2Bn downloads in the first week of July 2016
There are clear drivers demanding that Windows enables the ability to create symlinks to non-admin users:
- Modern development projects are increasingly portable across operating systems
- Modern development tools are symlink-aware, and many are optimized for symlinks
- Windows developers should enjoy a development environment that is at least the equal of others
How to use Symlinks
Symlinks are created either using the mklink command or the CreateSymbolicLink API
mklink
- There is no change in how to call mklink. For users who have Developer Mode enabled, the mklink command will now successfully create a symlink if the user is not running as an administrator.
CreateSymbolicLink
- To enable the new behavior when using the CreateSymbolicLink API, there is an additional dwFlags option you will need to set:
Value | Meaning |
SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE 0x2 | Specify this flag to allow creation of symbolic links when the process is not elevated |
Example Use
In the example below:
- A subfolder folder called “animals” containing three files (cat.txt, dog.txt, and fish.txt)
- (green) The mklink command is executed to create a symlink called “pet.txt” pointing at the “animalsdog.txt” file
- (blue) When the contents of the current folder are listed, the symlink can be seen (yellow)
- (purple) When contents of pet.txt are queried, the content of the referenced file (“dog.txt”) is displayed
Once created, symlinks can be opened, loaded, deleted, etc., just like any other file. Here, the pet.txt symlink is being opened in Notepad (red):
How do I try it?
This new symlinks support first shipped in Windows 10 Insiders Build 14972, and will be formally delivered in Windows 10 Creators Update. We are also working with the owners of open-source community tools such as Git and npm so they know symlink improvements are coming and can make the necessary changes to better support symlinks on Windows.
We encourage you to take this new feature for a spin and be sure to let us know via the Windows 10 Feedback hub or on Twitter etc. (see below). Please sign up for the Windows Insiders program if you haven’t already to try out symlinks!
Symbolic Links – Create Folder / Directory Alias in Windows How to create true directory aliases in Windows (not shortcuts) using Symbolic Links with mklink, Powershell or Junction (Sysinternals)
Table of Contents
In this post we’ll explain the concept of symbolic links, a neat feature available in NFTS-enabled Windows operating system that can be used to create “proxies” or “pointers” for files or folders located elsewhere. In a nutshell, a symbolic link is a file-system object that has the sole purpose to point to another file system object : the object acting as a pointer is the symbolic link , while the one being pointed to is called target .
If you think that we’re talking about shortcuts, you’re wrong: although there are indeed similarities between the two concepts, the actual implementation is completely different. To better understand these kinds of difference, though, is advisable to step back and talk about what aliases and shortcuts actually are and how they do differ in a typical operating system.
Introduction
In general terms, an alias is defined as an alternate name for someone or something: the noun is derived from the Latin adverb alias, meaning “otherwise” and, by extension, “also known as” (or AKA). In information technology, and more specifically in programming languages, the word alias is often used to address an alternative name for a defined data item, which can be defined only once and then referred by one or multiple aliases: such item can be an object (i.e. a class instance), a property, a function/method, a variable, and so on. In short words, we can say that an alias is an alternate (and arguably most efficient) way to reference to the same thing. This eventually led to a more widespread usage, also including e-mail aliases – a feature of many MTA services that allows to configure multiple e-mail prefixes for a single e-mail account – and other implementations based upon the overall concept.
The main characteristic of an alias lies in the fact that it is an alternative reference to the same item: it different from other common terms frequently used in information technology, such as the shortcut – which defines a quicker way to reach – yet not reference to – a given item, target, or goal. To explain it even better, we could say that the alias is a different way to address something, while the shortcut is a different way to reach it. Such difference can be trivial or very important, depending of what we need to do.
Shortcut vs Simbolic Links
The perfect example to visualize the differences between shortcuts and aliases is a typical Windows operating system. From the desktop to the start menu, a Windows environment is tipically full of shortcuts: we do have shortcuts to run programs, to look into the recycle bin, to open a folder (which can contains other shorcuts), and so on. In a nutshell, a Windows shortcut is basically just a file that tells Windows what other file needs to be opened whenever it gets clicked, executed or activated: we could just say that a shortcut is a physical resource designed to redirect to another (different) resource: it help us to get there, yet it’s not an alternate way to address it. This means, for example, that its reference won’t be affected if we delete it. It also means that we can change its reference at any time, without altering its status (it will still be a shortcut) and without affecting its previous reference (cause they are completely different things and not related in any way).
An alias doesn’t work like that: whatever command we issue to it would likely have effect on the actual item to which it refers: we could say that an alias is a different (and additional) path to access the same resource. As a matter of fact, it ultimately depends on how the alias feature has been implemented on that specific scenario we’re dealing with, but that’s how it usually works in most programming languages, operating systems, database services and similar IT environments that usually make use of the concept. That’s how it works on UNIX, where aliases are called links, and also in Windows NTFS, where they are known as symbolic links.
Shortcuts
In modern Windows, a shortcut is an handle that allows the user to find a file or resource located elsewhere. Microsoft Windows introduced such concept in Windows 95 with the shell links, which are still being used nowadays: these are the files with the .lnk extension you most likely already know (the .url extension is used when the target is a remote location, such as a web page). Microsoft Windows .lnk files operate as Windows Explorer extensions, rather than file system extensions.
From a general perspective, a shortcut is basically a regular file containing path data: we can think on them as text files which only contain a URI for a file, a folder or any other external resource (UNC share, HTTP(s) address, and so on): that URI gets executed whenever the user clicks on (executes) them, as long as the operating system allows it – which is the default behaviour by default, but can be disabled for security reasons. Anyway, shortcuts are treated like ordinary files by the file system and by software programs that are not aware of them: only software programs that understand what shortcuts are and how they work – such as the Windows shell and file browsers – are able to “properly” treat them as references to other files.
Symbolic Links
Conversely from aliases, NTFS symbolic links (also known as symlink) have been implemented to function just like the UNIX aliases: for that very reason, they are transparent to users and applications. They do appear just any other standard file or folder, and can be acted upon by the user or application in the same manner. Such “transparency” makes them perfect to aid in migration and/or application compatibility tasks: whenever we have to deal with an “hardcoded” path that cannot be changed, and we don’t want to physically move our files there, we can create a symbolic link pointing to that address and fix our issue for good.