Error: cannot execute binary file

When running a file, your shell will display the cannot execute binary file error or exec format error if Linux fails to recognize the file as a shell script or executable file. This error typically occurs when a binary file for a certain processor architecture is run on a different architecture e.g., an x86 executable is run on an ARM CPU.

A binary file

Solution

We can solve this issue by figuring out what our machine’s architecture is with the command below:

uname -a

Next, we will run the following command to check the executable file’s architecture:

file filename

This gives us better insight into which architecture we require. For instance,​ if we are working on 32-bit Linux and the executable file requires a 64-bit architecture, we could download a 64-bit virtual machine to run the file.

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved