I have the following directory structure to start with

~/a/src -> /home/user/b/sync/src

I created a symlink

cd ~/a/src
ln -s ../bin bin-xyz

now bin-xyz is a broken link, and there is no way of cd-ing into it.

What i am looking for?

How to create a symlink inside a symlinked folder such that the relative path is not broken. For example,

 cd ~/a/src/bin-xyz 


 cd ~/b/sync/src/bin-xyz

should work provided that there is bin directory in ~/a/ or ~b/sync/

Why i am looking for this ?

I am syncing ~/b/sync/src across machines, where ~/a/ is my workspace in both the machines but the user name of the machines differ. So, having a relative path that works means an easier work-flow for me.

I am using bittorent sync for syncing.

Thanks :-)

1 Answer 1


now bin-xyz is a broken link

The reason for that is hopefully obvious: Either .. has to refer to the actual parent directory or else it would be completely ambiguous.

Since ~/a/src -> /home/user/b/sync/src, I presume with that as $PWD and ln -s ../bin bin-xyz you're trying to link /home/user/b/sync/src/bin-xyz to /home/user/a/sync/bin. In which case you should just use absolute paths:

 ln -s /home/user/a/sync/bin /home/user/b/sync/src/bin-xyz

The reason ln doesn't fill in the .. blanks in this regard is that it, unlike your current shell, has not been tracking your movement and has no way to know that by .. you meant something other than the real parent directory.

It's (maybe?) implied in your question that you can't do this because there are actually two different systems involved. That implies either a network share is mounted or you use the same block device with both, implying in turn an XY problem -- can't solve that without more details.

  • there is no special networking issue. Anyways, thanks for your comment i have been able to resolve it by ln -s ../../../a/bin bin-xyz now the symlink file can be synced and still work on my other machine. As my directory structure ,at the user level, in both the machines is the same.
    – AmeBel
    Jun 19, 2014 at 7:45
  • Isn't that exactly the same as ln -s /home/user/a/sync/bin bin-xyz? If this is just one drive and no networking is involved, what is the issue with the "two machines"? I'm confused as to why you think you need to use a relative .. path.
    – goldilocks
    Jun 19, 2014 at 13:26
  • i wanted to use relative path because the user names in the two machines, that i sync, differ. And what i meant by "there is no special networking issue" is that, there is no share mount or usage of the same block device which were suggest in the answer above.
    – AmeBel
    Jun 20, 2014 at 15:12

You must log in to answer this question.

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