Search code examples
linuxcommandhyperlinkbin

Linux: bin file not found when executed using a symbolic link in another folder


In Linux, I have a symbolic link to a .bin file in:

~/bin>

So, I have:

~/bin>l

lrwxrwxrwx  1 myuser mymachine    56 Sep 27 09:25 Myfile.bin -> ./otherFolder/Myfile.bin

If I execute this .bin in the "bin" folder, there is no problem:

~/bin>Myfile.bin

But if I execute it from another folder:

~/other>../bin/Myfile.bin

the result is:

-bash: /home/myuser/bin/Myfile.bin: No such file or directory

Why is this happening?

Thanks.


Solution

  • I think your symlink is broken.

    What is the output of

    cd ~/bin
    file ./otherFolder/Myfile.bin
    

    ?

    edit

    If you do :

    ~/bin>Myfile.bin
    

    you run Myfile.bin from PATH, and it's not necessary ~/bin, depends of your $PATH variable.