Symbolic Links are quite useful because they allow us to store files wherever we want to, regardless of a program’s need for its files to be stored in a particular place.
I’ll be giving an overview of everything about symbolic links. The links are quite easy to create too. There are a few ways to do that and I’ll also be explaining those ways in easy to follow steps below.
Symbolic Links: What Are They? 🤔
These links represent actual files or folders. Normally, shortcuts take you to where files, apps, or folders are located. But these links stand in as the files and folders themselves.
When you create a symbolic link to a folder, there is no difference between clicking that folder or clicking the link.
This feature is why most folks call them “advanced shortcuts”. These links can come in handy in many situations such as the one below.
Let’s say you have a warfare app that needs its files stored in a particular directory (say C:\Warfare). But you want to declutter that particular directory and there’s nothing else you can afford to remove except the files for the app.
What you’ll do is move the app’s directory to another directory (say D:\GamesFolder), then all you’ll have to do is create a symbolic link at C:\Warfare that will point to D:\GamesFolder.
What now happens is that whenever you try to launch your app, it’ll naturally go to C:\Warfare and then get directed back to D:\GamesFolder for the files by the symbolic link you created.
All of these processes will be done without any delay and the app will still believe that its files are stored in its preferred location. Sounds cool, right?
Other Reasons For Using Symbolic Links
You can use the links for a variety of reasons. It also helps when working with programs like Google Drive.
You can sync folders Google Drive using the links even if the files and folders aren’t located in their own folder (something most apps insist upon before syncing).
You don’t have to worry about symbolic links taking up double the memory space too. The links are virtual folders (contain nothing more than code that maintains an appearance of the folder or files you linked).
It is also important to know that not only Windows 10 supports symlinks. Windows Vista, 7, 8 versions also support symbolic links.
The Two Types Of Symbolic Links
The generally known names for the two types of links that exist are hard links and soft links. But I need to point out that Windows refers to soft links as symbolic links.
So, in any Windows document, you’d see the two types of links as hard links and symbolic links.
To ensure better understanding, I will stick to the hard and soft links naming as I explain their uses and differences.
Soft (Symbolic) Links
Soft links redirect queries to where the actual files or folders exist.
So if you click on a soft link to get the files of a program, you’ll be taken to where the files of that program exist.
Hard links are quite different and more intense. These links don’t redirect queries.
When you click on them, the links act as if the files and folders you’re looking for are exactly in the link (hard) you clicked on.
This is what makes apps and programs not know any better that their files or folders have been moved from preferred storage locations to other directories.
Creating Symbolic Links In Windows
Learning how to create symbolic links just needs a little basic knowledge about systems and using command prompts.
You can create symbolic links using the two ways explained below.
The first one is internally sourced while the second option involves downloading a graphical tool that would make the job a whole lot faster and probably easier especially for folks who aren’t tech-savvy.
If you’re not comfortable with downloading 3rd party tools, then you should just stick to the first option.
Creating Symbolic Links Using The mklink Command
The first step is opening a command prompt with administrator privileges.
There’s a Windows 10 update (Creator’s Update) that allows you to use the command prompt (without admin privileges) for something like this but you’ll have to enable developer mode first.
To enable the mode, follow this navigation.
Settings > Update & Security > For Developers
If you want to avoid all the steps above, just go to your Start menu and look for the Command Prompt shortcut, right-click the shortcut and then choose Run As Administrator in the pop-up menu that appears to launch the prompt window.
Note: If you don’t run the command prompt with admin privileges when you get to enter the command, you’ll get a message saying you don’t have sufficient privilege to perform the operation.
Creating a Soft Link Pointing To a File
This command creates a soft link at Link that points to the file at Target.
mklink Link Target
Creating a Soft Link Pointing To a Directory
This command creates a soft link too but one that points to a directory at Target.
mklink /D Link Target
Creating a Hard Link Pointing To a File
This hard link command creates a link at Link that points to a file at Target.
mklink /H Link Target
Creating A Directory Junction
A directory junction just basically means creating a hard link pointing to a directory.
mklink /J Link Target
These are the commands you need to create symbolic links using the mklink command.
I’ll give an example of how a command will look below. I’m going to try and create a directory junction.
mklink /J C:\Warfare C:\GamesFolder
Please note that when you have paths that have spaces, you will need to tweak your command by adding apostrophes. Here’s an example below.
mklink /J “C:\War fare” “C:\Games Folder”
Creating Symbolic Links With This 3rd Party Graphical Tool (Link Shell Extension)
Both of these files (package + tool) can be found on the download page.
When you’re done with downloading and installing the tool. Launch it.
You’ll see the option to access your files and folders. Do that and navigate to the file or folder you want to create a link to.
When you find the file or folder, hover on it and right-click. In the pop-up menu, select the option that reads Pick Link Source.
Now go to the file or folder you want to create the link to. When inside, use the Drop As option to create a link to the file or folder you earlier selected in this new file or folder you chose.
There are three options for you to choose from when you click on Drop As.
- Hardlink – Creating a hard link to a file.
- Junction – Creating a hard link to a directory.
- Symbolic Link – Creating a soft link to both files and directories.
Using a third-party graphical tool to create links is quite straightforward. The important thing is to know the functions of the menu (as outlined above).
There are always security concerns whenever you want to download third-party apps and you should know that you are open to a level of risk (minimal in this case).
You will get a warning that this third-party tool download can’t be done securely and your Windows Defender might even tell you it’s unsigned.
If you choose to, still go ahead and download it.
Deleting Symbolic Links In Windows
This is quite easy to do. You can delete it by right-clicking on the link and selecting the Delete option in the pop-up menu that appears.
Just like you would delete any file or folder, you could use shortcut keys too. Select a link and click Delete.
But I have to warn you about the danger of deleting the actual files or folders instead of the link (especially in cases of hard links).
These links fool applications. If you’re not careful they might trick you into deleting files or folders too.
You might want to double-check which one’s the Link and which one’s the Target first before deleting anything.
Creating Symbolic Links In Linux (For Files)
Creating links in Linux relies on ln and -s (used in choosing which symbolic link). The format below is quite easy to follow.
ln -s [target file] [symbolic filename]
In – This command creates links between source files and directories
-s – This is the command for specifying the type of command you want.
Target File – This is the file you’re creating a link for.
Symbolic Filename – Named symbolic because it will act as the target file itself but is just a link.
Verifying created links by directory listing is done by using the detailed list command.
In cases where you don’t input any symbolic filename, the link will still be created. But it will be created in the same directory as the target file.
Creating Symbolic Links In Linux (For Folders)
The idea here too is similar to creating symlinks in the files above. Here’s the basic format to follow.
ln -s [specific file or directory] [Symlinks name]
All you have to do is input the directory you want to create a link to and input the name of the link you want to create, then run the command.
ln -s /user/local/download/fm /games
In this command line above, I’m trying to link the /user/local/download/fm directory to the /games folder.
Once the link is created in the /games folder, any attempt by programs to access the directory in the folder will work as if the directory is in the folder.
The More Common Symbolic Link Options (Linux)
Below is a list of some of the useful symbolic link options that users might want to try out.
Please note that Symbolic Links are also called command-line switches.
- -backup[=CONTROL] – this command backs up the existing destination files.
- -f, –force – this command removes existing destination files.
- -L, –logical – this command dereference symbolic link targets.
- -d, -F, –directory – gives super users the privilege of attempting hard links.
- -l, –interactive – this is a prompt before destination files are removed.
- -r, –relative – this helps in creating a link that is relative to the link location.
- -n, –non-dereference – symbolic links to the directory are taken as files.
- -s, –symbol – This ensures symbolic, not hard, links are created.
- -P, –physical – making hard links to symbolic links directly.
Removing Symbolic Links In Linux
There are two ways you could change or remove symbolic links in Linux. Both ways are easy to follow.
- By the unlink command
- By the rm command
Using The Unlink Command
This way of removing symbolic links in Linux is straightforward.
All you have to do is follow the format (command) below whenever you’re trying to remove the links.
unlink [symbolic link to remove]
To follow this format with an actual link, all you have to do is input the symbolic link’s name (the one you used in creating the link).
Using The rm Command
This is also similar to the command above, they basically both do the same thing. Here’s the format below.
rm [symbolic link to remove]
Symbolic links can help make our system storage spaces much more uncluttered. They also make syncing easier especially for folks who use Dropbox, Google Drive, and other applications like it.
Many apps and programs prefer their files stored somewhere specific and this sometimes causes users to have other empty memory options while a particular memory option is full.
Using these links above, you can just give the app or program the impression that the files and folders it needs are still in its preferred specific location when in reality, it’s just a hard link that’s there.
If you have any issues creating links whether in Linux or Windows, please use the comments section below to explain your problem and I’ll get back to you with fixes.