How to Create and Use Symbolic Links (Symlinks) on a Mac


MacBook Air M2 keyboard and trackpad
Marcus Mears III / How-To Geek
Create a symbolic link by opening a Terminal and using the following command:

ln -s /path/to/original /path/to/link

Symbolic links, also known as symlinks, are special files that point to files or directories in other locations on your system. You can think of them as advanced aliases and here’s how to use them in macOS.

What Are Symbolic Links?

In macOS, you can create regular aliases in the Finder. Aliases point at files or folders, which are more like simple shortcuts.

"Make Alias" in Finder

A symbolic link is a more advanced type of alias that works in every application on the system, including command-line utilities in the terminal. A symbolic link you create appears to apps to be the same as the original file or folder it’s pointing at, even though it’s just a link.

They work much like symbolic links do on Linux, since both macOS and Linux are UNIX-like operating systems. PC users can also use symbolic links, but symbolic links on Windows work a little differently.

Let’s say you have an application that needs its files stored at /Library/App that you want to store somewhere else on the system—for example, in /Volumes/App. You can move the App directory to /Volumes/App, and then create a symbolic link at /Library/App pointing to /Volumes/App. The program will try to access its folder at /Library/App, and the operating system will redirect it to /Volumes/App.

Confused? Let’s take a look at a real-world example. Let’s say you have many Steam games taking up space on a primary Mac partition that you want to store on an external drive instead. By default, these files happen to be stored at “/Users/chris/Library/Application Support/Steam/steamapps”. First, move the “steamapps” directory to an external drive called “Data” which has the pathname “/Volumes/Data”.

To complete the procedure, create a symbolic link that points to the new location of the files (that’s “/Volumes/Data/steamapps”) within the “/Users/tim/Library/Application Support/Steam/” directory. To Steam and any other process, the symbolic link looks just like a normal folder, as if the original never moved. In reality, those files are stored elsewhere, and the symlink works as a very convincing signpost.

This is entirely transparent to the macOS operating system and the applications you use. It allows you to move files around for your convenience and is especially handy if you only have limited space available on an internal drive. You can move your symbolic link around, and it will point back to the original file.

In addition to symbolic links, which are sometimes called “soft links”, you can instead create “hard links”. A symbolic or soft link points to a path in the file system. For example, let’s say you have a symbolic—or soft—link from /Users/example pointing to /opt/example. If you move the file at /opt/example, the link at /Users/example will be broken. However, if you create a hard link, it will actually point to the underlying inode on the file system. So, if you created a hard link from /Users/example pointing to /opt/example and later moved /opt/example, the link at /Users/example would still point to the file, no matter where you moved it. The hard link works at a lower level.

You should generally use standard symbolic links (soft links) if you’re unsure what to use. Hard links have some limitations. For example, you can’t create a hard link on one partition or disk pointing to a location on another partition or disk, while you can do that with a standard symbolic link.

Create Symbolic Links With the ln Command

To create a symbolic link on a Mac, you’ll need to use the Terminal app.

Press Command+Space, type “Terminal”, and then press “Enter” to open Terminal from Spotlight search. Navigate to Finder > Applications > Utilities > Terminal to launch Terminal.

Launch Terminal using macOS Spotlight

Run the ln command in the following form. You can specify either a path to a directory or file:

ln -s /path/to/original /path/to/link

The -s here tells the ln command to create a symbolic link. If you want to create a hard link, you’d omit the -s. Most of the time, symbolic links are the better choice, so don’t create a hard link unless you have a specific reason for doing so.

Here’s an example. Let’s say you wanted to create a symbolic link in your Desktop folder that points to your Downloads folder. You’d run the following command:

ln -s /Users/name/Downloads /Users/name/Desktop

Create symbolic link in macOS Terminal

After creating the link, you’d see your Downloads folder appear on your desktop. It’s actually the symbolic link you created, but it will look like the real thing. This folder will appear to contain all the same files as your Downloads folder. That’s because it does—they’re just different views pointing to the same underlying directory on the file system.

Symlink to Downloads in the Desktop folder

If your file path contains spaces or other special characters, you’ll need to enclose it in quotation marks. So, if you wanted to create a link on your desktop to a folder named “My Files” inside your user directory, you’d need something like the following command:

ln -s "/Users/name/My Files" "/Users/name/Desktop/My Link"

To ease typing file and directory paths into the Terminal, you can drag and drop a folder from the Finder window into the Terminal. The Terminal will automatically fill in the path to that folder. It will enclose the path in quotation marks if necessary, too.

Create a symlink with spaces

If you need to create a symbolic link in a system location your user account doesn’t have access to, you’ll need to prefix the ln command with the sudo command, like so:

sudo ln -s /path/to/original /path/to/link

Remember that, on modern versions of macOS, you won’t be allowed to write to certain system locations without changing a low-level firmware option due to System Integrity Protection. You can disable that feature, but we recommend that you don’t.

Use the sudo command to create a symlink

RELATED: How to Disable System Integrity Protection on a Mac (and Why You Shouldn’t)

How to Delete Symbolic Links

You can delete symbolic links like you would any other type of file. For example, to delete a symbolic link in Finder, right-click on it (or use Control+click) and select “Move to Trash” from the context menu.

Delete symbolic link using Finder

You can delete links from the command line using the rm command, which is the same command you’d use to remove other files. Run the command and specify the path to the link you want to delete:

rm /path/to/link

Remove symbolic link using Terminal

How to Create Symbolic Links With a Graphical Tool

The Finder can create aliases, but they won’t work quite like symbolic links. Aliases are just like desktop shortcuts on Windows. They aren’t treated as true, transparent symbolic links.

To create symbolic links in Finder, you’ll need a third-party utility or script. We recommend the open-source app SymbolicLinker for quickly adding an option to the right-click (Control+click) Finder context menu.

Download the .DMG file and open it. In Finder, click on Go > Go To Folder and enter “~/Library/Services” which takes you to your username’s Services folder. Drag the “SymbolicLinker.service” file into this folder.

Add SymbolicLinker.service to your Services folder

Double-click on the service to run it, then click “Open” to confirm that you’re happy to run it.

Open SymbolicLinker.service for the first time

You’ll now find a “Make Symbolic Link” option under your right-click (Control+click) Services menu.

"Make Symbolic Link" using the Services menu

Now move the symbolic link wherever you want it, and it will always point back to the original folder.


If you haven’t used them before, symbolic links can take a little time to wrap your head around. Once you do, you’ll find them a powerful tool for doing something that you often can’t do with a regular alias.

macOS is packed with features that increase productivity, speed up your workflow, and provide more flexibility with how you use your computer. If you found this tutorial useful, make sure you use Automator and Shortcuts workflows to resize images, understand basic macOS Terminal commands, and boost Mac productivity with a few simple tips.

You can even install macOS software via the Terminal using Homebrew.





Source link

Previous articleHow much Bitcoin does billionaire George Soros have?
Next articleCan You Sleep with Too Many Pillows? – LifeSavvy