linux: cannot execute binary file: Exec format error

created at 12-13-2021 views: 2986

The problem of cannot execute binary file encountered under linux system is generally caused by the following situations:

  1. Non-root user or no execution permission
  2. The compilation environment is different (the program is copied from other operating environments)

solution

For the first case

chmod +x  can be used to increase the execution authority

For the second case

it is recommended to copy the program binary package and recompile the program. Because during the actual operation, I found that I packaged the entire operating system environment of the American VPS and downloaded it to the local server. After decompressing the program, there would be problems as shown in the question. I was puzzled, and the system was centos5. 2. In the end, it was found that the two compilation environments were different:

  • my American VPS is AMD64 bit processor
  • The local server is an INTEL32 bit processor

The hardware compilation environment of the two is different, which causes this problem. Of course, some downloaded programs are non-binary packages that can be executed directly, but the problem occurs because the kernel cannot match the CPU, intel is x86, and amd is amd64 or 32-bit version , Correspondingly download clearly. I hope this article is helpful to the friends who see it.

created at:12-13-2021
edited at: 12-13-2021: