Benedek Antók

What is a symlink?

A blue and an orange portal folder

This is an introduction to a very useful, yet little known feature of modern file systems.

Have you ever played Portal?

Symlinks work pretty much like portals, except that they are files. Sort of.

They look like files, they (mostly) act like files, but they are not really files.
They allow actual files to "exist" in multiple places at the same time.

"But you can just copy files, so what's the point?"

There are a few benefits:

"Okay cool, but shortcuts can do all that!"

Kind of. They are pretty similar, but symlinks are more seamless.

Here's an example to illustrate how that can come handy:

Let's suppose you have a program that you have installed on your SSD.
You use it often, so you want it to open quickly, but it also takes up a massive chunk of your drive.

A schematic drawing showing the folder structure of the program JumboLab

It would be nice if you could move parts of it to your HDD, but it has to have all its files on the same drive...
Or does it?

No! You can fool it with symlinks.

Move some files over to the HDD, replace the originals with links, and you're good to go.

The previous drawing, but now there's also a hard drive, and a portal folder which connects it back to the SSD

Okay, let's see another example:

You have a bunch of files in the cloud. What if you wanted to access some these on all of your devices?

Say you want to have your pictures (which are stored in the cloud) in your user home directory. You can do that with symlinks.

First, set up syncing on your computer with the cloud provider of your choice. They usually put a directory into your user home directory with all of your cloud files in it.

Then, you can make a symlink in your home directory that points to your Pictures in the cloud sync directory. Done.

A drawing of someone's personal folders, with a portal folder in the Cloud storage sync directory connecting to the Pictures directory

All right, so how can you go about creating symlinks?

You have some options. You can either use the command line, or download an utility.

I prefer the command line for many things, but for this job, I like to use a little program called Link Shell Extension:

A screenshot with the Link Shell Extension context menu open, mouse hovering over the 'Pick Link Source' item Another screenshot, with the Drop As... - Hardlink item highlighted

As you can see, it's pretty straightforward to use. But if you prefer not to install any third party apps, the command line has got you covered:

mklink "C:\Path\To\Symlink" "C:\Target\Of\Symlink"

So to access your pictures stored in the cloud from your home directory, you could execute:

mklink /D "C:\Users\User\Pictures" "C:\Users\User\Cloud storage sync\Pictures"

The /D switch is needed because we are creating a directory type symlink.

In UNIX-based systems, the command is:

ln -s target_directory symlink_location

That's pretty much all you need to know to get started with symbolic links.
Mind you, there is a lot more to the topic than what we've covered in this article.

If you are keen on learning more about file systems in general, I encourage you to do so.
For NTFS, the page for Link Shell Extension is a good place to start, with clear explanations and illustrations.


Screenshots: Link Shell Extension by Gerhild and Hermann