I have a directory called Foo. I want a symlink to it, on the same level as it, called foo.

ln -s Foo foo creates a symlink in Foo pointing back to itself.

$ mkdir lntmp && cd lntmp
$ mkdir Foo
$ touch Foo/file
$ ln -s Foo foo
$ tree
└── Foo
    ├── Foo -> Foo
    └── file

1 directory, 2 files

What I want to achieve is

$ tree
└── foo -> Foo
└── Foo
    └── file
| improve this question | | | | |
  • Did you try a hardlink (without -s) instead of a symlink? – IQV May 8 '17 at 13:27
  • Thanks for the suggestion. It turns out hardlinks don't work on directories, only files. – EngineerBetter_DJ May 8 '17 at 13:29
  • According to the manpages the option -d (--directory) creates hardlinks to directories... – IQV May 8 '17 at 13:37
  • Sadly that option isn't present on macOS (which I should've been more explicit about using) – EngineerBetter_DJ May 8 '17 at 13:37
  • Odd, considering how macOS is the only one which does allow directory hardlinks (for Time Machine purposes)... Most other systems and filesystems don't, to avoid infinitely nested directories. – user1686 May 8 '17 at 13:38

If you're using macOS (according to question tags), then your disk is probably using a case-insensitive filesystem – so foo and Foo are identical and you cannot have both in the same directory.

Instead of a symlink, try mkdir foo or touch foo and see what you get.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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