0

https://www.youtube.com/watch?v=-XosJtC0vyA

In the current directory(test), I have used

echo date > date.sh ; chmod u+x date.sh

to create date.sh and make it executable.

Then I used

ln -s date.sh ../date.sh.sym1
ln -s ./date.sh ../date.sh.sym2

to create two symbolic links in the parent directory from which I typed

./date.sh.sym1
./date.sh.sym2

The result was that both showed command not found. Then in the parent directory, I used

ln -s test/date.sh date.sh.sym3

to create another symlink. This time it becomes executable after I typed

./date.sh.sym3

Is it because symlink can only be created from parent to child ? (FreeBSD 10.2)

PPJack
  • 95
  • 1
  • 6

1 Answers1

1

The user in the video typed the ln commands incorrectly. The first parameter to ln is the target (what you're linking to) the second paramter is where the place the link. When you do ln -s date.sh ../date.sh.sym1 you're placing a symlink in the parent directory to something in the current directory. The user in the video then changed directories to the parent directory. From that frame of reference the OS was expecting something called date.sh in the current directory. Hence the command not found errors.

The second ln, ln -s test/date.sh date.sh.sym3 created a link to test/date.sh. That path (test/date.sh) could be resolved, which is why it ran.

Michael Albers
  • 3,721
  • 3
  • 21
  • 32