Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

scenario :

  1. I'm in a place that is not in PATH
  2. I have a file name dofoo that is executable
  3. I want to create symbolic link in /usr/bin that points to dofoo in current directory

quite hard to get the basics. I can do with

$ cd /usr/bin
$ sudo ln -s /previous/path/dofoo
$ cd /previous/path

but I'd like to be this done with single command. here's what I have tried(assuming I'm in /previous/path):

$ sudo ln -s dofoo /usr/bin/dofoo
$ /usr/bin/dofoo
bash: /usr/bin/dofoo: Too many levels of symbolic links
share|improve this question
up vote 6 down vote accepted

The command should look like

sudo ln -s $PWD/dofoo /usr/bin

This will produce the expected result. The manpage is a bit unclear about TARGET (at least to me).

share|improve this answer
+1. the content of a symbolic link is the path to the target file, so always provide the absolute or relative path, not just the program name. – glenn jackman May 29 '13 at 2:41
Fantastic answer! This is useful in soooo many places and I've spent hours dealing with the consequences of not knowing this. Just shows, if you ask the right questions... Thanks – RobinLovelace Apr 3 '14 at 8:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.