Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What command is used to create a symbolic link/soft link?

share|improve this question
┌── ln(1) link, ln -- make links
│   ┌── Create a symbolic link.
│   │                         ┌── the path to the intended symlink
│   │                         │   can use . or ~ or other relative paths
│   │                   ┌─────┴────────┐
ln -s /path/to/original /path/to/symlink
      └───────┬───────┘
              └── the path to the original file/folder
                  can use . or ~ or other relative paths
$ echo content > original
$ ln -s original symlink
$ ls -la original symlink
-rw-r--r--  1 grgarside  staff    8 28 Jan 18:44 original
lrwxr-xr-x  1 grgarside  staff    8 28 Jan 18:44 symlink -> original
$ cat symlink
content

For more information about ln(1) see the man page.

To create a symlink to replace a system directory (e.g. if you want to have /Users pointing to another disk drive), you need to disable System Integrity Protection. You can re-enable it after the symlink is set up.

share|improve this answer
4  
If only man pages were as clear as your answer! – Adrian Lynch Jan 27 at 7:00
    
permission denied :S can you give me a hint? trying to create symlink for Users so I can use it on other hard disk and ssd has just symlink. thanks – Ewoks Mar 13 at 21:36
    
@Ewoks /Users is protected by SIP. You can disable System Integrity Protection to set up the symlink (and re-enable it after if you wish). I've added this to the answer. – grgarside Mar 13 at 21:44
    
You don't need to disable SIP to symlink SIP-protected folders/files, e.g. ln -s /Users /Users/myuser/all-users works perfectly. You only need to disable SIP if you want to create the symlink in a SIP-protected folder (as you would if you wanted to create any other directory entry there). – patrix Mar 13 at 22:51
2  
@patrix I've edited my answer to clarify; feel free to edit further. – grgarside Mar 14 at 7:40

The command is called ln. If used with the option -s it will create a symbolic link in the current directory:

ln -s /any/file/on/the/disk linked-file
share|improve this answer

I know this question is explicitly asking about the Terminal, but if you're in GUI Land and don't want to enter Terminal Land, you can use SymbolicLinker. This puts a "Make Symbolic Link" option in your Services menu in Finder.

A context menu for a folder, showing a "Services" submenu, with "Make Symbolic Link" hilighted

A context menu for a symbolic link, with "Make Symbolic Link" hilighted

share|improve this answer
    
I'd love to know why this was downvoted so I can make higher-quality answers from now on :) – Ben C. R. Leggiero Apr 27 at 22:43
3  
probably because the question was "How can I create a symbolic link in Terminal?" But I am not downvoting you :) – vedrano Apr 29 at 14:55
    
Does this imply that there's simply no way to do this from the Mac Gui without installing software? Also, I can't help thinking that this could have been done with Automator. – Edward Falk May 11 at 14:36
    
@EdwardFalk as far as I know, there isn't. I was hoping, like windows, dragging while holding Alt or Shift or something would do it, but nope! – Ben C. R. Leggiero May 11 at 15:08

It's just ln -s <source> <destination>.

share|improve this answer
    
Welcome to Ask Different! While you answer is technically correct, we are looking for more than just a simple one line answer. Further explanation or examples is helpful to other users. – Allan Apr 27 at 19:15
    
Sometimes a quick, simple answer is exactly what's needed. Detailed answers are great, but not when you're just looking for a quick syntax check. – Thomas Higginbotham May 5 at 14:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.