I have a directory to which I want to create a symbolic link. The commands I used were:
cd workspace_b4a
cd android-sdk-linux
ln -sv build-tools/20.0.0/lib/ platform-tools/lib
The output was:
‘platform-tools/lib’ -> ‘build-tools/20.0.0/lib/’
However, Nautilus says that platform-tools/lib
is a broken link and ls -l platform-tools/lib
shows the both build-tools/20.0.0/lib/
and platform-tools/lib
in red. What am I doing wrong?
Thanks everyone for your suggestions. I found it easiest to understand how to do it (though I still don't understand the logic behind it) with:
Assuming you are in directory
/path/to/common/root
:which has a subdirectory
build-tools/20.0.0/lib
:and subdirectory
platform-tools
, but no file or directoryplatform-tools/lib
:and you want to make
platform-tools/lib
a symlink tobuild-tools/20.0.0/lib
, then you can either make it an absolute link:or you can make it a relative link:
while noting that the relative link must be relative to the symlink file itself, not to the location where you run the
ln -s
command. To make sure you don't get that wrong (and because you get convenient tab completion with it), there are two options:Either go to the symlink's directory first, and create the symlink there:
Or use the
-r
option to makeln
figure out the relative path while you specify paths relative to your current directory:You can link to a non existing PATH (either file or directory)
Why someone would do that ?
Latter, i can create foo file/dir, and link will work.
while directory
build-tools/20.0.0/lib/
does not exsists, your link will be broken.I'd assume that you are in a directory
and you want to create a symbolic link for '/build-tools/20.0.0/lib' dir it. You can do that by
EDIT : The output of
Will also be changed.