~/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?
man ln
?dir1/ln2dir21
symbolic link is relative todir1
. The correct command would beln -s ../dir2/dir21 dir1/ln2dir21
.man ls
tells me "ln [OPTION]... [-T] TARGET LINK_NAME" ie. TARGET is first so that's the target of the command, LINK_NAME is second which is the link (-s tells it symbolic) created. SPACES are delimiters, ie. "dir2/dir21" is the TARGET and "dir1/ln2dir21" the LINK_NAME in format path/file (where file can be the name of a file or a directory (file contains more files; in posix/unix/linux everything is a file in a way)