Symlinks

This post is mostly documentation and a reminder to future me, who will inevitably need to work with symbolic links, and will perpetually forget how exactly to do so.


MacOS

On macOS, the command for creating symbolic links is ln.

My most common use case for a symbolic link is to use an external hard drive to backup and restore my iPhone. My Mac only has 256gb of storage, so moving a ~50gb backup file to a separate drive is preferrable.

On macOS, phone backups are stored here: /Users/<username>/Library/Application Support/MobileSync/Backup

You can get there by running cd ~/Library/Application\ Support/MobileSync/

macOS looks for a Backup folder here. So, to store your backups elsewhere, you simply need to create a symbolic link called Backup in this MobileSync folder. Wherever the symbolic link goes is where your backups will go.

Simply create a folder named Backup somewhere on your external drive.

To point macOS to the external drive’s backup folder, we run this:

ln '/Volumes/<drivename>/phoneBackups/Backup/' '/Users/<username>/Library/Application Support/MobileSync/'

This will add a symbolic link for the Backup folder on your external drive in your computer’s local MobileSync directory.

Notice how it ’took’ the folder name from the source. This is why you needed to make a folder named Backup on your external drive.

I was confused when reading documentation, because I thought I needed to make a Backup folder that would be turned into a symoblic link folder. This is not the case.

Now, your mac’s phone backup utility will use your external hard drive.

Lastly, what happens when you unplug the hard drive? The symlink for the “Backup” folder disappears. It’ll reappear when you plug the drive back in.



Windows

On Windows, I used a utility named Junction to make a symbolic link.

Long story short, I wanted to play Beat Saber without having to deal with Steam force-updating the app, necessitating re-installation of mods. There is a utility app called BSManager that helps to install and run a fixed version of Beat Saber.

BSManager installs Beat Saber again in a new directory, but any songs you had on your original / main version of Beat Saber do not come along to whatever version BSManager installed.

I understand that song formats and highscore files are not backwards compatible, and this may be why BSManager didn’t add a way to link these game folders.

I didn’t want to duplicate the gigabytes of song files between the two game versions, so I used junction to link these two folders together.

Here is a helpful StackExchange answer where I learned about the ‘junction’ tool.

Note: I think that is sad that in the sprawl of stuff that Windows provides, cli symlinking is recommended to be done by a depreciated tool. However, it did get the job done.

This is the exact command I ran:

\junction.exe "C:\Users\tadhg\BSManager\BSInstances\1.40.8\Beat Saber_Data\CustomLevels" "C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\CustomLevels"

Where the steamapps\common was where I had my song files, and BSInstances is where I wanted them accessible from.


This page will likely be updated with more examples as I find uses for them.