I was trying to create a symbolic link using the following command:

ln -s "~/Foo Bar/" Foo

... but it didn't work (i.e. when I go into finder and try double clicking it, it says that it's pointing to an invalid path and prompts me to delete the alias or fix it). I had to rename the folder to FooBar and then run the following command:

ln -s ~/FooBar/ Foo

How can I create the link without having to remove the space from the folder's name?

I'm looking for a way to do this in Terminal and not in Finder's UI.

  • 1
    While Gordon Davisson is right, you should be aware that aliases and symbolic links (symlinks) are different. ln -s makes symlinks. The Finder makes aliases. They are almost identical in practical, common use, but it's important to recognize that they are different. Symlinks point to a directory path, while aliases point to a file. If you have both pointing to the same file and you move the file to a different folder, then make a new file in the old folder, the alias will point to the moved original and the symlink will point to the new file.
    – Cajunluke
    Feb 17, 2011 at 20:46
  • 1
    @Cajun: thanks for the clarification. It's confusing that finder shows a symbolic link's "Kind" property as "Alias".
    – Senseful
    Feb 17, 2011 at 21:25
  • 4
    Tab completion is a wonderful thing too, if you were to do this: ln -s ~/Foo<tab> (where <tab> denotes the actual ⇥ (tab) key on your keyboard), if there is only one folder that starts with "Foo" in ~ then it will automatically expand the path to ~/Foo\ Bar/. Feb 17, 2011 at 23:40

2 Answers 2


The quote marks are preventing ~ from being expanded to your home folder, so you need to either quote just the part with the space in it:

ln -s ~/"Foo Bar/" Foo

Note: exactly how much is quoted doesn't matter, as long as the space is in the quoted portion and the ~/ isn't. ~/Foo" "Bar/, ~/"Foo Bar"/, ~/Fo"o B"ar/ etc are all equivalent. Also, single- and double-quotes have the same effect on spaces (although they differ on other characters), so ~/'Foo Bar/', ~/Foo' 'Bar/ etc would also work.

You could also use an escape to prevent the space from being treated as a separator:

ln -s ~/Foo\ Bar/ Foo
  • 5
    You can serious quote JUST the space? That's awesome! Feb 17, 2011 at 23:37
  • Or "$HOME/Foo Bar/".
    – wchargin
    Jul 25, 2018 at 20:43
  • @wchargin That'll work. Note that unlike ~, $HOME should be in double-quotes to prevent confusion if your home directory contains spaces or other weird characters. "$HOME/Foo Bar/" (as you suggest), "$HOME"/Foo" "Bar/, "$HOME"/Foo\ Bar/, etc will work. Jul 26, 2018 at 4:38

I tested it myself. I don't have a problem with a space in it:

    $ ln -s "/Users/joe/test/foo bar"/ linkToFoo_Bar

ls shows: $ linkToFoo_Bar -> /Users/joe/test/foo bar/ and it works in terminal and finder without any problems.

  • 10
    You used a full path, not the ~ helper. Feb 17, 2011 at 23:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .