Direction of a symlink
touch a
ln -s a b
The above command creates a symbolic link which originates from "b" and points to "a":
lrwxrwxrwx 1 root root 1 Dec 20 23:41 b -> a
The question is that how to say that correctly? If it is correct, then why is the reverse direction i.e "b" is the source and "a" is the target. And which entity is the symbolic link itself?
Solution 1:
The syntax of ln
is parallel to that of cp
and mv
.
cp a b
creates a file called b
containing the content of file a
.
ln –s a b
creates a symbolic link called b
that points to a
(i.e., provides access to the content of a
). Similarly,
ln a b
creates a hard link (a new directory entry) called b
that refers to the file a
(which must already exist, unlike the case of the symbolic link). In all cases,
the first argument is the source (of the data)
and the second argument is the thing that the command creates.