Symlink use cases: Shortcuts, App config files

Shortcuts 🥱

Maybe you have shortcuts on your desktop to your favorite folders, or maybe you symlink your active projects in your home directory for quick bash access.

For example:

ln -s /User/alex/Apps/2020/appthing /User/alex/appthing

This will create a shortcut to ~/Apps/2020/appthing directly in my home dir, i.e. cd ~/appthing

Notice how I used absolute paths when creating the symlink.

You don’t need to use absolute paths, but it’s the best way to stay out of trouble. But as you’ll see below, there are times when relative symlinks are useful.

App config files 🤔

First I’ll explain the project (it’s very simple) and then I’ll talk about why I like it.

Here’s the folder structure of my project:

➜  appthing tree .
├── configs
│ └──
└── -> configs/

As you can see, there’s a configs folder containing some configuration This is linked to (a symlink file which, by the way, can be committed to version control):

cd appthing
ln -s configs/

Notice how I used relative paths when creating the symlink. This way the project can be cloned onto other computers or servers without the symbolic link breaking.

Here’s what my config file looks like:

➜  appthing cat
class config:
HELLO = "World"

and here’s what looks like:

➜  appthing cat
from config import config

Running it goes like this:

➜  appthing python

The point of using a symlink is to be able to quickly change the config file without needing to copy or move the current one.

Say that you needed another instance of this app running (with different config options) — you could make the new config file configs/ and quickly start testing them by swapping the symlink ln -s configs/

This is useful because

  • App configurations can easily be exchanged (e.g. cloning multiple instances of an app to run on different configs)
  • Working version of config file is same as app config. No need to copy the file after saving edits (i.e. cp configs/ ⛔)


Now get back to your projects, they are missing you ;)

Python Data Engineer, MSc. Physics

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store