3

Trying to run an executable file on terminal (I am using Tails live OS), but I keep receiving an error message. I have set permissions already. The command I wrote:

sudo ./home/amnesia/myfile

I receive "Command not found"?

I tried running it with or without sudo:

$ sudo /home/amnesia/myfile
sudo: unable to execute /home/amnesia/myfile: No such file or directory
$ /home/amnesia/myfile
bash: /home/amnesia/myfile: No such file or directory

Information about the file (it's a binary, not a script):

$ ls -l /home/amnesia/myfile
-rwxrwxrwx 1 amnesia amnesia 15327 Sep  3  2013 /home/amnesia/myfile
$ file /home/amnesia/myfile
ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared lies), for GNU/Linux 2.6.9, not stripped

Information about my system:

$ uname -a
Linux amnesia 3.16-3-amd64 #1 SMP Debian 3.16.5-1 (2014-10-10) x86_64 GNU/Linux
$ file /bin/ls
/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xd3280633faaabf56a14a26693d2f810a32222e51, stripped
Hodurrr
  • 195
  • What is the content of myfile? – Faheem Mitha Nov 08 '14 at 05:02
  • Does myfile have a proper shebang line? – PM 2Ring Nov 08 '14 at 05:55
  • If this is a binary blob (as opposed to a script), maybe it's this issue. – Joseph R. Nov 08 '14 at 11:40
  • @JosephR., my processor is 64 bit and the file is also 64 bit. So I don't think its that issue. – Hodurrr Nov 08 '14 at 17:32
  • Can you show us the output of uname -a ? – Mark Plotnick Nov 08 '14 at 18:41
  • @Mark Plotnick , Output is : "Linux amnesia 3.16-3-amd64 #1 SMP Debian 3.16.5-1 (2014-10-10) x86_64 GNU/Linux" – Hodurrr Nov 08 '14 at 20:02
  • Can you show us the output from ldd /home/amnesia/myfile ? You may need to install some additional libraries or another runtime linker to allow this older executable to run. Some discussion of this is at http://askubuntu.com/questions/60238/running-a-64bit-executable-on-a-64-ubuntu-lucid ; in that case, adding a symlink fixed the problem. – Mark Plotnick Nov 08 '14 at 20:42
  • 1
    Can you run the program without sudo? What is the output of ldd /home/amnesia/myfile? @JosephR. More precisely, I suspect this issue. – Gilles 'SO- stop being evil' Nov 08 '14 at 22:19
  • @MarkPlotnick, Ahhh the output of ldd/home/amnesia/myfile is: "not a dynamic executable." What does that mean? – Hodurrr Nov 09 '14 at 16:11
  • @Gilles, It won't run without sudo. Do I need to get a library? – Hodurrr Nov 09 '14 at 16:13
  • So it's either a static executable, or an executable in some different format (unlikely), or a script, or an archive that you need to unpack, or a corrupt file, or something. What does file /home/amnesia/myfile say? – Gilles 'SO- stop being evil' Nov 09 '14 at 18:48
  • @Gilles, Don't think it's static. Output of file /home/amnesia/myfile is: 'ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared lies), for GNU/Linux 2.6.9, not stripped' – Hodurrr Nov 09 '14 at 18:50
  • Strange. Is the executable publicly available? One more thing: that's the output of file /bin/ls? And what's the exact error from running /home/amnesia/myfile (not as root) (copy-paste!)? – Gilles 'SO- stop being evil' Nov 09 '14 at 18:59
  • @Gilles, file /bin/ls: "/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xd3280633faaabf56a14a26693d2f810a32222e51, stripped" ... Now the output of /home/amnesia/myfile is "bash: /home/amnesia/myfile: No such file or directory" – Hodurrr Nov 09 '14 at 19:10

4 Answers4

6
$ /home/amnesia/myfile
bash: /home/amnesia/myfile: No such file or directory
$ file /home/amnesia/myfile
ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared lies), for GNU/Linux 2.6.9, not stripped

So myfile exists, but running it gives the message “No such file or directory”. This happens in the following circumstance:

  • The file depends on a loader — it's a dynamically linked executable, and these need a loader program to load the dynamically linked libraries. (The loader can also be the interpreter designated by a shebang line, but bash detects this case and gives a different error message.)
  • The loader file is not present.

The message “No such file or directory” is really about the loader, but the shell doesn't know that the loader is involved, so it reports the name of the original file. I explain this in more detail in “No such file or directory” lies on Optware installed binaries.

Why can't you run this program? Because you don't have the dynamic loader for 64-bit executables.

$ uname -a
Linux amnesia 3.16-3-amd64 #1 SMP Debian 3.16.5-1 (2014-10-10) x86_64 GNU/Linux
$ file /bin/ls
/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xd3280633faaabf56a14a26693d2f810a32222e51, stripped

Your system has a 64-bit kernel, but the rest of the system is 32-bit. Linux supports this configuration (a 64-bit kernel can run both 64-bit programs and 32-bit programs, but a 32-bit kernel can only run 32-bit programs). The kernel can load the program just fine; you would be able to run a statically-linked amd64 executable. However, you don't have the 64-bit loader (/lib64/ld-linux-x86-64.so.2), nor presumably any 64-bit library. So you can't run dynamically-linked amd64 executables.

Why would you run a 64-bit kernel with a 32-bit userland?

  • To use more than about 3GB of physical memory. (This isn't the only way — another possibility is to run a 32-bit kernel that supports PAE.)
  • To be able to run 64-bit binaries, e.g. by booting on the live OS and then chrooting into an installed 64-bit system somewhere.
  • To reduce maintenance effort for the distribution: provide a single kernel for recent hardware, and make it 64-bit.
  • To run 64-bit virtual machines (some VM engines require a 64-bit kernel to run a 64-bit VM).

I don't think Tails provides a 64-bit system. You should get a 32-bit version of the executable. If you can't, use some other distribution (possibly in a virtual machine).

0

if you havent: chmod

chmod u+x /home/amnesia/myfile

And remove the '.' from the begning. it needed when you in same directory as of file is

sudo /home/amnesia/myfile

here is demo: Demo

Hackaholic
  • 2,051
0

I suggest checking the following:

  • Run file /home/amnesia/myfile. This will determine the file type you are trying to execute;
  • Run the script without sudo to get a more meaningful message;
  • If it's something like a shell script, a set -x will also help you figure out what's going on. You can also run the script with sh -x;
  • Could be a broken shebang line (ex: bad interpreter). Paste the output of head -5 /home/amnesia/myfile;
  • Could be that you have 'DOS' newlines in your script. If that file is a script with DOS newlines, a simple dos2unix myfile or perl -pi -e 's/\r\n/\n/g' input.file may fix the problem;
  • Okay I put 'file /home/amnesia/myfile' and the output is: 'ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared lies), for GNU/Linux 2.6.9, not stripped' – Hodurrr Nov 08 '14 at 16:45
0

I had the same problem. On Debian 7.8 the fix was to install the lsb package:

apt-get install lsb

I had to install a similar package (don't remember exactly which) on CentOS.

Michael Mrozek
  • 93,103
  • 40
  • 240
  • 233
Pawel
  • 1