8 Answers
Reset to default
132
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?
Improve this answer
answered Jun 13, 2012 at 3:07
LawrenceCLawrenceC
74.8k1717 gold badges132132 silver badges217217 bronze badges
5
-
33
"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!
–superuser
Commented Jun 13, 2012 at 4:18
-
1
It turned out my binary was a Windows exe file :P
–forzagreen
Commented Dec 18, 2018 at 13:39
-
3
How can we solve this? I am sure i get the same issue, but this answer does not really tell me a solution : /
–Newskooler
Commented Mar 2, 2019 at 20:08
-
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.
–LawrenceC
Commented Apr 21, 2019 at 15:21
-
1
Wow, I have never see a vote count so high still perfectly balanced with the question!
–IronEagle
Commented Apr 24, 2023 at 1:37
Add a comment |
44
Try to run it using ./executablefilename instead of using sh executablefilename. It's not a shell script after all.
Improve this answer
answered Jun 13, 2012 at 1:27
RidDeBakTiYarRidDeBakTiYar
59633 gold badges66 silver badges1010 bronze badges
2
-
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
–cchapman
Commented Jun 19, 2018 at 15:38
-
I feel so silly
–Akaisteph7
Commented Jan 2, 2024 at 20:12
Add a comment |
18
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).
objdump shows the binary is 64-bit elf64-x86-64
uname shows my machine is 32-bit i686
$ ./FF.Communicator bash: ./FF.Communicator: cannot execute binary file$ uname -mpioi686 i686 i386 GNU/Linux$ objdump -a ./FF.Communicator ./FF.Communicator: file format elf64-x86-64./FF.Communicator
objdump on a working binary on my machine shows it is 32-bit elf32-i386
$ 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.
For Mac OSX users, you can find out the architecture info of a specific file using the "file" command:
$ file filename_here
Improve this answer
edited Apr 7, 2023 at 19:57
Brambor
12511 gold badge11 silver badge77 bronze badges
answered Jun 19, 2015 at 11:55
gaoithegaoithe
54144 silver badges88 bronze badges
1
-
Thank you! Just in case,
/bin/objdump -f -- '/usr/bin/id' | sed -rne 's/^architecture: (.*),.*$/\1/p';
also.–Artfaith
Commented Nov 19, 2023 at 8:27
Add a comment |
9
I'm making some wild guesses here, but it looks like the following is happening:
- You log in over SSH, triggering
bash
to run your~/.profile
or~/.bashrc
to set up your environment for you (this is normal). - 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
. - 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.
Improve this answer
answered Jun 12, 2012 at 21:51
Darth AndroidDarth Android
38.5k55 gold badges9898 silver badges113113 bronze badges
Add a comment |
8
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 )
Improve this answer
answered Oct 24, 2018 at 14:01
Nasir Mahmood Nasir Mahmood
8111 silver badge11 bronze badge
2
-
Well this is very possible explanation on docker/podman/container env when using
CMD
, thank you–Benyamin Limanto
Commented Jan 19, 2023 at 6:24
-
1
A workaround for this might be to use
/bin/bash -c w
meaning that bash should not try to interpret /usr/bin/w as a shell script but rather run the one-line shell script containing: "w".–JohannesB
Commented Oct 26, 2023 at 11:13
Add a comment |
binary file consists of machine instructions the processor can understand.Your operating system does not mean the same executable will run.move back and forth between the processor instruction set compatible with will usually work well,if they are not compatible CPU will not be able to understand instructions.
Improve this answer
answered Jun 12, 2012 at 22:29
acoh Fachaacoh Facha
18744 bronze badges
Add a comment |
You are running wrong version of the installer, for example, 64bit machine and trying to install 32bit version of the installer.
Improve this answer
answered Jul 25, 2018 at 8:43
kwaikwai
1111 bronze badge
Add a comment |
To add a wee bit to LawrenceC's perfect answer:
I recently encountered this error on some gcc
-compiled files:
~/c_trials $ ./bb05-bash: ./bb05: cannot execute: required file not found
I thought I was going insane... a real wtfo moment. I finally figured it out:
I had recently moved this file (and the folder w/ all the files) from my Raspberry Pi 3 running
bullseye
to this Raspberry Pi 5 runningbookworm
.
After re-compiling on the RPi 5, everything was copacetic (not insane):
~/c_trials $ gcc -o bb05 bb05.c~/c_trials $ ./bb05blah, blah, blah
Lessons learned:
- All ARM machines are not created equal.
- Differences in
glibc
version may also upset your apple cart.
Improve this answer
edited Jan 28, 2024 at 22:22
answered Jan 28, 2024 at 22:10
SeamusSeamus
19822 silver badges1111 bronze badges
Add a comment |
You must log in to answer this question.
Not the answer you're looking for? Browse other questions tagged
- linux
- bash
- ssh
- debian
.
Not the answer you're looking for? Browse other questions tagged
- linux
- bash
- ssh
- debian
.