Why ln -s creates relative broken links?

I have an issue with ln -s on Ubuntu 14.04, while using it in the following scenario:

$ cd ~/programming/tmux/
$ ln -s tmux ~/bin/tmux
$ ls -l ~/bin/tmux
lrwxrwxrwx 1 USER USER 4 sie 31 11:02 /home/USER/bin/tmux -> tmux

Why is it like so? When I create it giving the absolute path everything works fine:

$ ln -s ~/programming/tmux/tmux ~/bin/tmux
$ ls -l ~/bin/tmux
lrwxrwxrwx 1 USER USER 4 sie 31 11:02 /home/USER/bin/tmux -> ~/programming/tmux/tmux
Asked By: Patryk

||

When you write

ln -s VALUE link_name

it creates a symbolic link with value VALUE. This is what you got. If you want to create a relative link, it is best to cd to the directory where you want to put the link:

$ cd ~/bin
$ ln -s ../programming/tmux/tmux .

Shell completion will help you.

Answered By: vinc17
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.