Linux cannot run binary file

How can I resolve the error «cannot execute binary file»?

PATH is an environment variable which contains a list of folders which the shell searches for programs. ls for example, usually refers to /bin/ls , and your shell finds it by going through the folders listed in PATH one-by-one until it finds it, or if it doesn’t find it in any of them, it gives up. I suppose a better starting point would be, what is the output of echo $PATH ? (edit: the export command is a way to define an environment variable in bash.)

Ah. I warned you not to shut the system down 😛 Can you get console access to it (physical monitor+keyboard attached)? Try booting the system in single-user mode (might be labelled as recovery mode) and see if you can get to a root shell.

@David you won’t see any output after typing export PATH=/bin:/user/bin:/sbin:/usr/sbin . It’s a silent command.

7 Answers 7

Usually that error message means Linux doesn’t recognize the file as a shell script or as an executable file.

Typically the cause is running an executable on the wrong architecture — if you try to run x86 executables on an ARM CPU, this message comes up.

Did /usr/bin/id get overwritten, possibly?

«if you try to run x86 executables on an ARM CPU, this message comes up.» That was EXACTLY what caused it. Thanks everyone for your inputs!

How can we solve this? I am sure i get the same issue, but this answer does not really tell me a solution : /

To resolve, you need to use an ARM binary and not an x86 binary. If the source is available, you can recompile/rebuild under an ARM system. If the source is not available, check with the vendor for an ARM binary. The official JRE from Sun, for example, has both x86 and «embedded» or ARM versions. You have to use the ARM version.

Try to run it using ./executablefilename instead of using sh executablefilename. It’s not a shell script after all.

I had this problem when trying to run kiwix-serve on my raspberry pi. My overall solution I believe was to adjust the file permissions (it was not set to executable by anyone by default) and then ran it as ./kiwix-serve

The problem is running a binary for a different processor architecture. You can use objdump (from binutils) to check architecture of binaries. You can use uname to check architecture of a machine.

e.g. I encountered this error «cannot execute binary file» when installing FF.Communicator — a firefox plugin for chrome (so I can run pages that use java applets).

$ ./FF.Communicator bash: ./FF.Communicator: cannot execute binary file $ uname -mpio i686 i686 i386 GNU/Linux $ objdump -a ./FF.Communicator ./FF.Communicator: file format elf64-x86-64 ./FF.Communicator 
$ objdump -a /bin/ls /bin/ls: file format elf32-i386 

Using these tools you can check architectures of machines and binaries — not just intel architectures but any processor.

Читайте также:  Linux удалить открытый файл

For Mac OSX users, you can find out the architecture info of a specific file using the «file» command:

I’m making some wild guesses here, but it looks like the following is happening:

  1. You log in over SSH, triggering bash to run your ~/.profile or ~/.bashrc to set up your environment for you (this is normal).
  2. At some point it tries to execute /bin/id to get your uid, which fails, causing integer expression error, and terminating the script before it can set up your $PATH .
  3. Because your $PATH is not set, bash is only able to run commands with the full path specified.

Use export PATH=/bin:/usr/bin:/sbin:/usr/sbin to fix the $PATH issue until you can fix the root cause of /bin/id failing.

This means that you are trying to execute a binary file using your bash script which is not intended to be run as you trying it to be. It is already a binary file and you are trying your $SHELL to parse and run it.

in a very simple example, if you try to run `w’ command like

$ bash w /usr/bin/w: /usr/bin/w: cannot execute binary file 

similarly you might be hitting the same method or as it looks from your code snippet.

While , for the remaining for your commands, Al these halt, shutdown , reboot etc commands are the root owned commands and need super-user prilveges to run and perform the required operation. normal users can’t run them another explanation is that these commands are placed at /sbin/ and /usr/sbin , which might not be in your $PATH variable ( which is used to validate commands in your custody )

Источник

Решение проблемы с ошибкой «bash: не удаётся запустить бинарный файл: Ошибка формата выполняемого файла»

В операционной системе Linux при запуске скаченного файла, либо при запуске самостоятельно скомпилированного файла вы можете столкнуться с ошибкой:

bash: /путь/до/файла: не удаётся запустить бинарный файл: Ошибка формата выполняемого файла

Если у вас англоязычная локаль, то ошибка будет примерно такой:

bash: ./program: cannot execute binary file: Exec format error

В самой ошибке вместо /путь/до/файла и ./program будет указан путь до файла программы, который вы хотите запустить.

Причинами данной ошибки могут быть:

  • попытка запустить 64-битный файл на 32-битной системе
  • файл скомпилирован для другой архитектуры (например, для ARM, а вы пытаетесь запустить его на ПК)
  • вы пытаетесь выполнить не исполнимый файл, а ссылку
  • файл размещён в совместной (shared) папке

Чтобы получить информацию о файле, который вы пытаетесь запустить, можно использовать утилиту file, после которой укажите путь до файла:

program: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=03ada11d91d298913990bfc074ccc3a380d26b69, with debug_info, not stripped

Здесь мы видим, что файл предназначен для 64-битной системы, об этом говорит запись 64-bit, для процессора с архитектурой x86-64.

program: ELF-32-bit LSB executable, ARM, EABI4 version 1 (SYSV), dynamically linked(uses share libs), for GNU/LINUX 2.6.16, not stripped

Этот файл для 32-битных систем, для процессора с архитектурой ARM EABI4.

Читайте также:  Linux имя сетевой карты

Если вы не знаете, какой битности ваша система, то выполните команду:

Для 64-битных систем будет выведено x86_64, а для 32-битных – x86.

О разрядности дистрибутивов Linux и о программ

На компьютер с 32-битным процессором вы можете установить только 32-битную операционную систему и в ней запускать только 32-битные программы.

На компьютер с 64-битным процессором вы можете установить как 64-битную ОС, так и 32-битный Linux. В случае, если вы установили 64-битный дистрибутив Linux, то в нём вы можете запускать и 64-битные программы и 32-битные. А если вы установили 32-битный дистрибутив, то в нём возможно запускать только 32-битные программы.

Итак, если у вас 32-битная система, а файл для 64-битной системы или даже для ARM архитектуры, то у вас следующие варианты:

  • скачать файл подходящей для вас битности и архитектуры
  • если вы самостоятельно компилировали файл из исходного кода, то заново скомпилируйте для процессора вашей архитектуры

Запуск ARM файлов в Linux

Часто можно запустить исполнимые образы ARM на amd64 системах если установить пакеты binfmt-support, qemu, и qemu-user-static:

sudo apt install binfmt-support qemu qemu-user-static

Заключение

Итак, ошибка формата выполняемого файла с невозможностью запустить бинарный файл возникает из-за несоответствия программы операционной системе или архитектуре процессора. Эта проблема не должна возникать, если вы установили программу из исходных репозиториев (кроме случаев неправильной настройки источников репозитория). При возникновении этой проблемы поищите файл, подходящий для вашей архитектуры или скомпилируйте файл из исходных кодов под архитектуру вашей операционной системы.

Связанные статьи:

Источник

Bash: ./filename : Cannot execute binary file

Please type file um.exe or file um (whichever is the name of your binary file). However, likely the generated binaries are for one reason or other Windows binaries. Also, if the program is public, you can post the link to the sources. Or just post the makefile here.

7 Answers 7

As you can see from the output of file um that you posted in a comment, your binary is a 64-bit binary.

32 bit systems cannot run 64 bit binaries, it only works the other way around.

This is the most common reason I’ve seen for this problem, using file will identify this quite quickly.

@JohnMerlino Either provide Hardware with the correct instruction set and a OS which enable it (AMD64 Hardware and OS for AMD64 Programs). or simulate/emulate/virtualize it (Virtual Box/JVM/. ) or get a version for your instruction set. You can not run Software for other Instruction set as native Programs.

Another solution for people who are having this problem except the part about unmatched bits is that running the file without the command «bash».

Just use chmod +x ‘path to the file’ and then run ‘the path to the file’ in terminal.This is how I solved my problem.

Читайте также:  Linux youtube no sound

For Googlers:

  • 32-bit or 64-bit? Check with file yourbinary
  • Permission to execute? Do chmod +x yourbinary
  • Path correct? Do ./yourbinary

Try making the file executable

But if this is a exe file compiled for Windows, you probably need to install Wine.

Another possible source of this error: trying to run a Linux binary executable on a Mac, or vice versa.

For instance, trying to run the true binary from my Mac on an Ubuntu box that I SCPed it to:

$ ./mactrue -bash: ./mactrue: cannot execute binary file: Exec format error 

If you’ve downloaded a binary and executing it fails with this error, check if you’ve downloaded the version for the wrong OS.

For me, copying the binary into Applications on my Mac then into my Path messed it up on my Mac. I’m pretty sure the Applications folder turned the binary into an Alias instead of an actual binary.

-bash: /usr/local/bin/terraform: cannot execute binary file mike$ file /usr/local/bin/terraform /usr/local/bin/terraform: MacOS Alias file 

I unzipped the binary from my Downloads again and just mv ed it to my Path and it worked fine.

mike$ file /usr/local/bin/terraform /usr/local/bin/terraform: Mach-O 64-bit executable x86_64 

Источник

cannot execute binary file

I have a binary executable that’s a part of an academic software package I’ve downloaded. I can’t seem to get it to run, and I don’t have access to the source code. I’ve tried the following things. Any thoughts? Many thanks.

$ chmod +x random_cell $ ./random_cell -bash: ./random_cell: cannot execute binary file $ file random_cell random_cell: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.4, not stripped $ ldd random_cell random_cell: is not an object file $ uname -m x86_64 

2 Answers 2

I ran into the same problem and this is the answer I came up with

$ ~/opt/Linux-3.11.0-i686/svn/bin/svn --version -bash: /home/fennellb/opt/Linux-3.11.0-i686/svn/bin/svn: cannot execute binary file $ file ~/opt/Linux-3.11.0-i686/svn/bin/svn /home/fennellb/opt/Linux-3.11.0-i686/svn/bin/svn: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, BuildID[sha1]=0x6b38ac5ac15af4334712b9bacc6646cabaefde9a, not stripped $ find /bin /usr/bin -maxdepth 1 -type f -print0 | xargs -0 file | awk 'BEGIN /ELF 64-bit/ /ELF 32-bit/ END ' ELF 32-bit count 1639 ELF 64-bit count 0 

Possible solutions: check to see if your CPU supports 64-bit Linux:

$ cat /proc/cpuinfo | egrep '^(model name|cpu MH|vend)' cpu MHz : 1200.000 model name : Intel(R) Pentium(R) Dual CPU E2140 @ 1.60GHz vendor_id : GenuineIntel 

(then Google the exact CPU name to find its specifications)

Then upgrade to a 64-bit Linux (if you can) — Download Ubuntu Desktop

One Alternative to run 64-bit code on 32-bit Linux is to use an true cpu emulator like qemu/bochs — Bochs — OSDev Wiki — with a 64-bit Linux image (or VM like xen if your CPU supports it).

Another is to ask your software provider to recompile for 32-bit.

(For me I am going to recompile from source.)

Источник

Оцените статью
Adblock
detector