Issue
Wanted to use gdb as a debugger in Linux Debian. Trying to run a binary I get this:
(gdb) r
Starting program: /usr/local/sbin/test
/bin/bash: /usr/local/sbin/test: No such file or directory
During startup program exited with code 127.
(gdb)
I guess it's supposed to be elementary. But I googled a lot and most common answer is
$ export SHELL=/bin/bash
This doesn't help. I also tried to change PATH for binaries execution, tried to run from different directory... Still the same.
Could you please help me with that?
Solution
/bin/bash: /usr/local/sbin/test: No such file or directory
There are two common causes of this:
- the file
/usr/local/sbin/test
doesn't exist - the file does exist, is a dynamically linked executable, and the ELF interpreter that it specifies does not exist.
For #1, the answer is obvious: you need a file to debug.
For #2, you can find out which ELF interpreter the file requires like so:
readelf -l /usr/local/sbin/test | grep interpreter
You likely have a 32-bit binary pointing to /lib/ld-linux.so.2
on a 64-bit system without 32-bit runtime support installed. Depending on the distribution you are using, something like sudo apt-get install libc6:i386
should do the trick.
Recent versions of the file
command also print the interpreter:
file ./a.out
./a.out: ELF 32-bit LSB executable, ... interpreter /lib/ld-linux.so.2, ...
Answered By - Employed Russian Answer Checked By - Katrina (WPSolving Volunteer)