Skip to main content

Create symbolic links in OSX

Published ago
Updated ago
2 min read

Symbolic links, or symlinks as they are also known. They can be seen as an alias, they are nothing more than "symbolic" paths that can point to any location on your computer, they are useful when you want to keep directories separate, but at the same time one inside the other. For example, if I have a repository with these files:

1- public
2-- wp-content
3-- .gitignore
4-- composer.json
5-- README.md
6

And I want the wp-content directory, within an installation with existing files:

1- public
2-- wp-admin
3-- wp-includes
4-- wp-config.php
5...
6

I couldn't just clone the repository, since the directory wouldn't be empty, then, the solution would be to create a symbolic path with the ln command. Its syntax is as follows:

1ln -s path/original path/symbolic
2

The -s parameter is what specifies that it is a symbolic link, in most cases you won't need anything else. Now my installation would look like this:

1- public
2-- wp-admin
3-- wp-content
4-- wp-includes
5-- wp-config.php
6...
7

Where wp-content is a reference to the original path, and by entering that directory I will simply enter the original, so every time I update the repository I will get the updates also in my installation.