Is it a ghost file? Is it a clone? It’s a symbolic link, and it’s so useful it just might blow your mind.
Every operating system has a helpful feature called symbolic links. This offers you a lot of benefits when combined with other applications or techniques. The ability to create symbolic links is a feature unknown to most computer users, but understanding the concept isn’t very difficult. I’ll explain what they’re all about and how you can use them to get out of your computer and installed services.
Wait, Aren’t They Just Shortcuts?
A good place to start is to imagine that symbolic links are like shortcut files — but don’t think that they’re the same. A shortcut file is a file that simply points to the desired file. Windows users are familiar with these shortcut files, as any installer will place a shortcut on your desktop to make it easier to run a program. A symbolic link, on the other hand, is a lower-level pointer that is written into the file system on your hard drive.
A symbolic link will make it look like the linked file is actually there, rather than it just being a shortcut. However, once you click on it, it’ll still be directed toward the actual file location and run the data found there. As reference for the curious, technically speaking a symbolic link is for a directory, a hard link is for a file, and a soft link is another term for a shortcut.
To better understand this, we’ll go into our first case study: use of symbolic links with Dropbox. If you’re wanting to synchronize something that you’d really rather have in a different folder besides the “Dropbox” folder, or if it’s something that can’t be moved without breaking some sort of functionality, you’ll have to find an alternate way to get Dropbox to synchronize those files.
For example, let’s say that you want to synchronize an entire folder (named “MakeUseOf”) that is full of files. If you create a shortcut in your Dropbox folder that points to the MakeUseOf folder, Dropbox will see the shortcut file and synchronize it. On another computer, you’ll see the same shortcut file, but if you click on it, you’ll come to a dead end. In this case, Dropbox just synchronized the shortcut file rather than the folder that the shortcut was pointing to.
To fix this issue, you can create a symbolic link. Since the symbolic link makes it look like the MakeUseOf folder exists in the Dropbox folder, even though it’s actually somewhere else, Dropbox will follow the symbolic link and start synchronizing the folder along with its contents. On the other computer, you’ll now have the MakeUseOf folder and its contents rather than just an invalid shortcut file.
There are four additional notes about symbolic links that you should be aware of.
- Although most applications will see symbolic links as the actual files they point to, they can still be distinguished as symbolic links via terminal tools. For example, Linux users can use the “ls -la” command and discover all of the symbolic links in the current folder.
- A joy about symbolic links is that they maintain the folder structure in which the symbolic link is contained. So, for example, let’s say a file named HelloWorld.txt was in the MakeUseOf folder and located at
/home/danny/MakeUseOf/HelloWorld.txt. If a symbolic link for the MakeUseOf folder was created in the Dropbox folder, and you went to look for HelloWorld.txt within the Dropbox folder, the file path would read
/home/danny/Dropbox/MakeUseOf/HelloWorld.txtrather than transforming back to the original/actual file path. This is a major reason why symbolic links work so well to “fool” applications such as Dropbox without causing them to crash in confusion.
- Symbolic links update themselves when the contents of the source file have changed, but they won’t update the symbolic path they form if the source file has been moved or deleted.
- The system won’t prevent you from creating a symbolic link within a symbolic link, so try to avoid doing so yourself. This will otherwise create an infinite loop that can cause issues for system-wide services like antivirus scanners.
Of course, as we’ve already discussed extensively, a primary reason for desktop users to use symbolic links is to extend the functionality of applications such as Dropbox and other similar cloud services like ownCloud and Copy. Additionally, it can also be used to create different locations for primary user folder such as “Music”, “Documents”, and ‘Pictures” (i.e. move those folders from your C:\ drive or Home folder to another location such as a secondary, larger hard drive).
Those are just a few ideas, but the full extent of the usefulness of symbolic links is limited only to your imagination.Mac OS X users can even synchronize their Mac apps via Dropbox.
Creating Symbolic Links
Now that you’ve been thoroughly schooled on the concept of symbolic links, how do you create them? This varies slightly among operating systems, but all of them require that you use a terminal/command line to create one. Under Windows, you can use the command mklink [flag] [source] [destination] to create a symbolic link to a directory. You must use the /j flag if you’re dealing with directories, the /h flag if you’re dealing with a file, or /d to essentially create a soft link/shortcut. For [source] and [destination], you’ll need to provide the paths to the files or folders in question.
Under Mac OS X and Linux, you can create a symbolic link by using the command “ln -s [source] [destination]”. This works for both files and folders so this one command is all you need. However, if you’re a Mac user who don’t want to dabble in the terminal, you can also use Automator to create a symbolic link.
Despite their usefulness, symbolic links are still more confusing to use than simple shortcuts — which is why they can’t be easily created in a graphical user interface. A lot of computer illiterate people don’t even understand the concept of shortcuts very well (i.e. they think a program has been uninstalled whenever they simply delete the shortcut off of their desktop), so including an easy way to create symbolic links could potentially cause problems. However, you shouldn’t have these issues after reading this article, so have fun!
Have you used symbolic links before? If so, what has been your most creative use? Let us know in the comments!
Image Credit: Almond Butterscotch