29

I created a symbolic Link from a File at "/opt/bladir/bla" to "bla". So "bla" is now in "/usr/bin/bla". But if I want to call "bla" at terminal, there comes the no such file or directory error. I looked up at "/usr/bin/bla" and the file is linking correctly at "/opt/bladir/bla".

What can be the error?

P.S. here is my terminal "entry": sudo ln -s /opt/bladir/bla bla

Thanks!

€: Problem solved. According to the Feature List, 12.04 should have Multiarch support... 'should'. I got the ia32-libs from synaptic and now the program wents just fine. As it looks, my symbolic links where correct.

Thank you for all the answers!

2
  • Just for the record: I got the same error. My problem was, that I was sitting in a deleted folder. To fix it: go out of the deleted folder, recreate the deleted folder, go into the new folder, try to create the symlink -> worked. ;)
    – 1stthomas
    Dec 22, 2020 at 9:42
  • To copy a broken symlink: `cp --no-dereference "theBroken" "theBroken.BKP # -P" Jun 10, 2021 at 9:20

4 Answers 4

23

EDIT: the solution below does not work. It is apparent that the symbolic link is broken, because file -L cannot open the symbolic link /usr/bin/bla. In this case, do the following:

sudo ln -sf /opt/bladir/bla /usr/bin/bla

using full paths (-f is to force overwriting the previous symbolic link, if there is one).

Hm. I think that the program "bla" may be looking for things that are installed in /opt/bladir and cannot find them. For example, it can be a shell script wrapper around a Java executable, with path relative to current directory: but your current directory is /usr/bin/, and not /opt/bladir/.

If the following works

file -L /usr/bin/bla

...then it is definitely not a problem with your symbolic link.

Check whether "bla" is a shell script that you can modify, take a look inside -- maybe you will find the problem. Possibly, adding /opt/bladir to your PATH would be a better solution.

7
  • The given command says: ERROR: cannot open `/usr/bin/bla'. I can't take a look inside "bla", it's a program, not only a shell script.
    – Sehe
    Sep 27, 2012 at 14:07
  • 1
    OK, redo the symbolic link with full paths, please.
    – January
    Sep 27, 2012 at 14:30
  • I came to that idea earlier by myself. Even with rm the old links and creating new ones, the error still appears. -sf also did not work.
    – Sehe
    Sep 27, 2012 at 14:52
  • OK. Plese run ls -l /usr/bin/bla and ls -l /opt/bladir/bla and report the exact output of these commands.
    – January
    Sep 27, 2012 at 15:00
  • @January what course of action would you recommend if file -L doesn't work?
    – abcd
    May 17, 2015 at 0:48
2

Seems that you had a different problem than me since you said,

"I looked up at "/usr/bin/bla" and the file is linking correctly at "/opt/bladir/bla"."

However, for others coming here, I wanted to put ~/julia-1.5.3/bin/julia on PATH via symlink, so I basically did cd /home/username/ and then sudo ln -s julia-1.5.3/bin/julia /usr/local/bin/julia. When I typed julia, it said bash: /usr/local/bin/julia: No such file or directory. When I did ls -all /usr/local/bin, I found the issue; it was linking to the dangling relative directory: julia -> julia-1.5.3/bin/julia.

Anyway, I just had to redo it with the absolute path, and it worked: sudo ln -sf /home/username/julia-1.5.3/bin/julia /usr/local/bin/julia

2

This isn't the case for this question, but another situation where this error could happen is if one of the directories has a space in it and isn't surrounded in quotation marks. for example:

ln -s my home/username/myfolder/a file.txt file.txt

will cause an error. but

ln -s my "home/username/myfolder/a file.txt" file.txt

will not.

1

Often this type of error message is shown, if you don't have execution bit enabled. Check whether the main file as well as the link is given execution permission.

I'm suspecting your /opt may be mounted from a separate partition and it isn't mounted with exec mount option

1
  • The excecution bit is set and /opt/ is not on a separate partition :/
    – Sehe
    Sep 27, 2012 at 14:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .