~/temp$ mkdir dir1
~/temp$ mkdir dir2
~/temp$ mkdir dir2/dir21
~/temp$ ln -s dir2/dir21 dir1/ln2dir21
~/temp$ mkdir dir1/ln2dir21/dir3
mkdir: cannot create directory ‘dir1/ln2dir21/dir3’: No such file or directory
What does the following command:
~/temp$ ln -s dir2/dir21 dir1/ln2dir21
create (there are no errors for the ln
command)? The created link dir1/ln2dir21
is red and it's type is lrwxrwxrwx
which seems to be a link. Then why can't create directory through that symbolic link?
The
dir1/ln2dir21
symbolic link you created is relative todir1
.The correct command would be:
As another test, if you go to
dir1
and createdir2/dir21
you will see that the red indicator will go away:You will see
ln2dir21 -> dir2/dir21/
in normal color (no red error color).~/temp$ mkdir dir1/ln2dir21/dir3
you can't create a directory in a directory that is inexistent usemkdir -p
ln -s dir2/dir21 dir1/ln2dir21
is not working, because you're a) linking to a file not a dirrectory and b) it should be a full path. https://stackoverflow.com/a/9104390so it should be:
ln -s ~/temp/dir2/dir21/ ./dir1/ln2dir21
and it should workl...