Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

I have 2 directories (FOO, LALA). I create a symbolic link in one of them like this

ln -s /etc/apache2 FOO/apache2

Afterwards I want to create another symlink, pointing to the same directory, but not using the initial directory but the symlink created. So I try

ln -s FOO/apache2 LALA/apache2

The problem is that the second link is invalid.

ls FOO/apache2

The above works and lists files in /etc/apache2

ls LALA/apache2

But this one doesn't. It just lists the link itself. If I add a slash at the end of each ls

ls FOO/apache2/

Works as well.

ls LALA/apache2/

I get ls: cannot access LALA/apache2/: No such file or directory/


If instead of

ln -s FOO/apache2 LALA/apache2

I do

cd LALA ; ln -s ../FOO/apache2 apache2

Then the symlink is valid

Any idea what's the difference?


Initial question from here http://stackoverflow.com/questions/10656666/use-a-symbolic-link-to-create-a-new-symbolic-linkhttps://stackoverflow.com/questions/10656666/use-a-symbolic-link-to-create-a-new-symbolic-link

I have 2 directories (FOO, LALA). I create a symbolic link in one of them like this

ln -s /etc/apache2 FOO/apache2

Afterwards I want to create another symlink, pointing to the same directory, but not using the initial directory but the symlink created. So I try

ln -s FOO/apache2 LALA/apache2

The problem is that the second link is invalid.

ls FOO/apache2

The above works and lists files in /etc/apache2

ls LALA/apache2

But this one doesn't. It just lists the link itself. If I add a slash at the end of each ls

ls FOO/apache2/

Works as well.

ls LALA/apache2/

I get ls: cannot access LALA/apache2/: No such file or directory/


If instead of

ln -s FOO/apache2 LALA/apache2

I do

cd LALA ; ln -s ../FOO/apache2 apache2

Then the symlink is valid

Any idea what's the difference?


Initial question from here http://stackoverflow.com/questions/10656666/use-a-symbolic-link-to-create-a-new-symbolic-link

I have 2 directories (FOO, LALA). I create a symbolic link in one of them like this

ln -s /etc/apache2 FOO/apache2

Afterwards I want to create another symlink, pointing to the same directory, but not using the initial directory but the symlink created. So I try

ln -s FOO/apache2 LALA/apache2

The problem is that the second link is invalid.

ls FOO/apache2

The above works and lists files in /etc/apache2

ls LALA/apache2

But this one doesn't. It just lists the link itself. If I add a slash at the end of each ls

ls FOO/apache2/

Works as well.

ls LALA/apache2/

I get ls: cannot access LALA/apache2/: No such file or directory/


If instead of

ln -s FOO/apache2 LALA/apache2

I do

cd LALA ; ln -s ../FOO/apache2 apache2

Then the symlink is valid

Any idea what's the difference?


Initial question from here https://stackoverflow.com/questions/10656666/use-a-symbolic-link-to-create-a-new-symbolic-link

Tweeted twitter.com/#!/StackSuper_User/status/203578153682219010
Source Link

Use a symbolic link to create a new symbolic link

I have 2 directories (FOO, LALA). I create a symbolic link in one of them like this

ln -s /etc/apache2 FOO/apache2

Afterwards I want to create another symlink, pointing to the same directory, but not using the initial directory but the symlink created. So I try

ln -s FOO/apache2 LALA/apache2

The problem is that the second link is invalid.

ls FOO/apache2

The above works and lists files in /etc/apache2

ls LALA/apache2

But this one doesn't. It just lists the link itself. If I add a slash at the end of each ls

ls FOO/apache2/

Works as well.

ls LALA/apache2/

I get ls: cannot access LALA/apache2/: No such file or directory/


If instead of

ln -s FOO/apache2 LALA/apache2

I do

cd LALA ; ln -s ../FOO/apache2 apache2

Then the symlink is valid

Any idea what's the difference?


Initial question from here http://stackoverflow.com/questions/10656666/use-a-symbolic-link-to-create-a-new-symbolic-link