Explainer: Links, Aliases and Bookmarks

Links, symbolic links, hard links, firmlinks, aliases and bookmarks are different ways of referencing files and folders to enable navigation to and from them. The generic term link normally includes symbolic (or soft) links and hard links; aliases are specific to macOS and are closely related to bookmarks. Firmlinks are a novel type introduced to join parts of the System and Data volumes in macOS Catalina and later.

To illustrate their creation and use, consider a user who likes to keep integrated project files in their Documents folder, containing text, images and movies which they store in respective folders elsewhere. The worst way to do that is to keep a copy of each file in the project folder and in the folder containing documents of that type. Keeping them in sync would be a nightmare, and they would waste storage space.

One cunning solution is to use duplicate entries in the file system, so that two (or more) link to the same file data. This is the hard link, and can only be created in Terminal using a command like
ln /Users/myname/Movies/myMovie.mov /Users/myname/Documents/Project1/myNewMovie.mov

That creates a second entry in the file system to the same file data. The file system keeps a count of those references to determine when to delete the file. So when you’ve finished using the hard link, you can put it into the Trash without the original being deleted. Only when there are no remaining references to that file will it then be deleted from the file system.

Hard links look and work exactly like the original, and can be moved around within the same volume freely. Copy one to another volume, though, and the copy will be a complete unlinked file. Hard links to files and to directories (folders) are one of the essential ingredients of Time Machine backups on HFS+, but as APFS doesn’t support directory hard links, Time Machine has to use a different backup format when stored on APFS.

Hard links are powerful and occupy no additional space on disk, but are relatively unpopular with users, who are more likely to use symbolic links or aliases instead.

Symbolic links also have to be made in Terminal, but are basically tiny text files containing the path to the linked file. The disk space they occupy is negligible, and they’re simple to create using the same ln command but with the -s option, like
ln -s /Users/myname/Movies/myMovie.mov /Users/myname/Documents/Project1/myNewMovie.mov

If you inspect the file myNewMovie.mov, it actually contains the text /Users/myname/Movies/myMovie.mov and remains valid wherever that path works to locate the source file. Such paths can be shorter and relative, allowing an enclosing folder to move around within that volume. They can also specify files on other volumes, so long as that path does so correctly. Change that volume name, though, and that path is broken.

Symbolic links are powerful and, in experienced hands, very reliable. They’re widely used, but Apple has long encouraged us to use Finder aliases, which try to get the best of both worlds and combine the path from a symbolic link with file system information to resolve the link in the event that the path becomes broken.

They date back to System 7 in 1991, but suffered from bloat as they incorporated additions like custom icons, resulting in some alias files growing to more than 1 MB in size. Apple revamped them and improved their resolution mechanisms during Sierra, so that current alias files should only be around 1 KB in size, and should be able to resolve links which would otherwise break symbolic links, and extend to other volumes, unlike hard links.

Users don’t normally see or manipulate bookmarks, as they’re a variant of aliases which are intended to be used in files for similar purposes. For example, the list of files shown in the Open Recent menu command in apps is assembled from a file containing bookmarks to each of those documents. Most lists of apps and files built by Launch Services are similarly reliant on bookmarks.

Embedding a file/folder path in a text or preferences file makes access simple, as any text editor will show the path. Try viewing a bookmark, though, and it’s incomprehensible.

I have an app for that: Precize both generates bookmarks, and will resolve any bookmark you paste into its Resolver window. Alifix can scan through folders identifying aliases which are wobbly or broken, so you can fix or remove them. My command tool alisma rectifies a longstanding omission in macOS by providing the facility to create and resolve aliases in scripts and at the command line. For example,
alisma -a sourcefile aliasfile
creates a Finder alias to the file at sourcefile in the alias file aliasfile, and
alisma -p aliasfile
resolves the alias file at aliasfile to return the full path to the original.

Symbolic links, aliases and bookmarks all work well in the right hands, but need maintenance. As you move and change folders, their paths become broken, and keeping those up to date is important if you want to be able to use them. Aliases tend to age badly: the macOS resolver mechanism can usually cope with small changes, but as more occur, it’s eventually going to be unable to locate the linked file/folder.

The worst problems arise when users try to build extensive alternate file systems using links or aliases. I’ve come across users with thousands of aliases, most of which have been left untouched for years; when they’re copied across to a volume with a different name, the result is carnage and many days spent manually recreating all those aliases. But used in moderation, both symbolic links and aliases can be invaluable tools.

Further reading

Copies, clones, links and aliases: summary in tables
Breaking the link
Finder Aliases and Bookmarks: a summary
Bookmarks, a type of Alias: their access and use