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?

3
  • you are logged in using admin ? Aug 4, 2011 at 15:16
  • Yes, it's a single-user system. All the other commands also are owned by admin:admin, and I can run them just fine. Aug 4, 2011 at 15:17
  • 1
    could be a 32 bits executable on 64 bits system. do "file your_exe_file"
    – Vincent
    Jan 29, 2018 at 14:58

2 Answers 2

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
5
  • That was the ticket: I needed a version compiled for uClibc. I compiled it myself and it worked fine. Aug 4, 2011 at 22:45
  • 3
    -ash: readelf: not found, lol.
    – nilskp
    Sep 19, 2016 at 14:14
  • 5
    @nilskp: assuming you're also in an "embedded" situation, run readelf on your dev box (against the target binary). Otherwise, install it (binutils package usually).
    – Mat
    Sep 19, 2016 at 14:52
  • Care to repost your answer to the original of this duplicate? I think your's is much more practical than the one here unix.stackexchange.com/a/11008/183837 Dec 6, 2018 at 10:16
  • apk add --update binutils in alpine linux
    – Eugene
    Oct 4, 2023 at 20:13
-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).

2
  • Yes, and I can run all the other programs in the directory with the exact same ownership and permissions just fine. Aug 4, 2011 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. Aug 4, 2011 at 16:20

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