49

Possible Duplicate:
“No such file or directory” lies on Optware installed binaries

I'm trying to add ebtables to a little router box. I went and got a binary compiled for the correct architecture, and put it on the box in /sbin/. When I do /sbin/ebtables, the shell says /bin/sh: /sbin/ebtables: not found, but I can do ls -l /sbin/ebtables and it shows up perfectly:

-rwxr-xr-x    1 admin    admin        4808 Aug  4 10:36 /sbin/ebtables

Any ideas about what's going on here?

Shawn J. Goff
  • 46,081

2 Answers2

56

It could be a missing dependency. Notably you'll get that type of message if the runtime linker ("program interpreter") set in the ELF header does not exist on your system.

To check for that, run:

readelf -l your_executable|grep "program interpreter"

If what it gives you does not exist on your system, or has missing dependencies (check with ldd), you'll get that strange error message.

Demo:

$ gcc -o test t.c
$ readelf -l test|grep "program interpreter"
      [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
$ ./test
hello!

$ gcc -Wl,--dynamic-linker -Wl,/i/dont/exist.so -o test t.c
$ readelf -l test|grep "program interpreter"
      [Requesting program interpreter: /i/dont/exist.so]
$ ./test
bash: ./test: No such file or directory
Mat
  • 52,586
-2

Are you running it as root? IIRC some bash implementations refuse to run anything from /sbin and /usr/sbin if you're not root.

I found this article for an explanation (maybe not related, talks about OpenSUSE).

Daniele Santi
  • 4,137
  • 2
  • 30
  • 30
  • Yes, and I can run all the other programs in the directory with the exact same ownership and permissions just fine. – Shawn J. Goff Aug 04 '11 at 15:29
  • 1
    You've misunderstood the explanation on that link. It's about bash's behavior when a command is not found in the $PATH. If you give the full path to the command, bash will run it. Also, this wasn't likely to be relevant in the first place since a “little router box” is unlikely to be running bash. – Gilles 'SO- stop being evil' Aug 04 '11 at 16:20