Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

marked as duplicate by Gilles, Caleb, Shawn J. Goff, Michael Mrozek Aug 6 '11 at 6:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
you are logged in using admin ? –  mr_eclair Aug 4 '11 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. –  Shawn J. Goff Aug 4 '11 at 15:17
add comment

2 Answers 2

up vote 5 down vote accepted

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
share|improve this answer
    
That was the ticket: I needed a version compiled for uClibc. I compiled it myself and it worked fine. –  Shawn J. Goff Aug 4 '11 at 22:45
add comment

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).

share|improve this answer
    
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 4 '11 at 15:29
    
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 Aug 4 '11 at 16:20
add comment

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