Symbolic Links: Show One Notes Folder in Two Places
A symbolic link makes one notes folder appear at a second path without copying anything. Run ln -s once and the same files are reachable from two places.
This guide shows the command, how to choose between absolute and relative paths, what happens when you move or delete things, and when a Finder alias is the better fit.
Quick answer
A symbolic link (also called a symlink or soft link) is a special file that refers to another file or directory by storing a path to it, giving you an alternative access path without duplicating the target's content. For a notes folder, that means one real folder and one pointer to it.
ln -s ~/Documents/notes ~/Projects/website/notesThe first path is the target, the folder that really exists. The second is the link name, the new place it should appear. Open ~/Projects/website/notes and you see the contents of ~/Documents/notes. Edit a file in either place and you have edited the one and only copy.
Step-by-step
Make the link with ln -s
The `ln` manual page lists the form ln [OPTION]... [-T] TARGET LINK_NAME. It also notes that ln creates hard links by default and symbolic links only with --symbolic (-s). Forgetting the -s is an easy slip, so check for it.
- Pick the real folder, for example
~/Documents/notes. - Pick where the second view should live, for example
~/Projects/website/notes. - Run
ln -s <target> <link name>in Terminal.
By default, the destination should not already exist. If something is already sitting at the link name, ln refuses; -f removes existing destination files, so use it only when you are sure what is there. If the link name is an existing folder, ln puts the link inside that folder instead, using the target's name. Pass the full link name, including its final component, so you get exactly the path you meant.
Keep the link name tidy, too. Spaces and odd punctuation make shell commands awkward, and some characters are best avoided in file names across Mac, Windows, and Linux.
Use a relative path when the folders travel together
The man page says a relative link is interpreted in relation to its parent directory, the folder that contains the link. That detail trips people up: a relative target is resolved from the link's location, not from the folder you were in when you ran the command.
Add -r (--relative) and, together with -s, ln creates the link relative to the link's location for you:
cd ~/Projects/website
ln -sr ../../Documents/notes notesUse a relative link when both folders live inside one tree you might move or sync as a unit, such as a project folder. Use an absolute path when the link should keep working wherever the link itself is moved.
Check it and open it
List the folder with ls -l and the link shows an arrow:
lrwxr-xr-x 1 you staff 21 Nov 18 09:12 notes -> /Users/you/Documents/notesThat -> is your proof. Open the link in Finder or in your editor and you land in the target folder.
Common problems and fixes
The link is broken
A symlink only stores a path. If the target is moved, renamed or deleted, the link is not automatically updated or deleted; it points at nothing and is called broken, orphaned, dead or dangling. Rename ~/Documents/notes and every link to it stops working.
The fix is to recreate the link with the new target. The destination already exists, so use -f:
ln -sf ~/Documents/field-notes ~/Projects/website/notesIf the link name is itself a link to a directory, add -n (--no-dereference) so ln treats the link name as a normal file instead of creating a new link inside the target folder.
Deleting the link versus deleting the target
Deleting a symbolic link does not affect its target, and commands such as rm and mv act on the link itself. Removing ~/Projects/website/notes leaves ~/Documents/notes and every file in it untouched.
Run rm on the link name without a trailing slash. Deleting files from inside the linked folder is different: those files are the real ones, and they disappear from both places at once.
Permissions still apply
A link does not grant access. You still need permission to read and write the real folder. If something refuses to open, check the rwx permission bits on the target.
Symlink or Finder alias?
macOS also has aliases. In Finder you choose File > Make Alias, and opening an alias opens the original. They look alike but aren't the same thing. Wikipedia notes that macOS aliases are not supported by Unix APIs such as `open()`, while symlinks are resolved by the file system itself.
In practice: use an alias when you only want a shortcut you click in Finder. Use a symlink when a Terminal command, script, or app that reads paths should see the folder at the second location.
Doing this with Carets
Carets is a fast, native notes and code editor for iPhone, iPad, and Mac that works on plain Markdown and text files kept in ordinary folders. That plain-folder model is why a symlink fits it: your notes are files, not rows in a database, so a second path to the same folder is just a second way to reach the same files.
Create the link in Terminal on your Mac as shown above. Then open the file or folder from whichever location is convenient, and organize the notes with files, projects, and tags as usual. Syntax highlighting keeps Markdown and any code snippets in those notes readable.
One honest limit: Carets edits files, it doesn't create links. Whether a particular location is reachable on iPhone or iPad depends on the system's file access, so open the link on that device before you rely on it there. Get Carets on the App Store for iPhone, iPad, and Mac.
Frequently Asked Questions
What is the difference between a symlink and a hard link?
A symlink stores a path to its target, so it can point to a directory or to a different volume, and it can be left pointing at nothing. A hard link always refers to an existing file and cannot cross volumes. ln makes hard links by default and symlinks only with -s.
What happens to my notes if I delete the symlink?
Only the link is removed. The target folder and the notes inside it are not affected. Deleting files from inside the linked folder is different, because those are the real files.
Is a Finder alias the same as a symlink?
No. Opening an alias in Finder opens the original, but Unix APIs such as open() do not support aliases, so command-line tools may not follow one. A symlink is resolved by the file system, so tools see the folder at the second path.
Why does my symlink show as broken?
The target was moved, renamed or deleted, and a symlink is not updated automatically. Recreate it with ln -sf pointing at the new location, or move the target back.