Looks like I cannot run any normal linux binaries if their name ends with .exe, any idea why?

$ cp /bin/pwd pwd
$ ./pwd

This is ok. But...

$ cp /bin/pwd pwd.exe
$ ./pwd.exe 
bash: ./pwd.exe: No such file or directory

$ ls -la pwd.exe 
-rwxr-xr-x 1 premek premek 39616 May  3 20:27 pwd.exe

$ file pwd.exe 
pwd.exe: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=2447335f77d6d8c4245636475439df52a09d8f05, stripped

$ ls -la /lib64/ld-linux-x86-64.so.2
lrwxrwxrwx 1 root root 32 May  1  2019 /lib64/ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-2.28.so
$ ls -la /lib/x86_64-linux-gnu/ld-2.28.so
-rwxr-xr-x 1 root root 165632 May  1  2019 /lib/x86_64-linux-gnu/ld-2.28.so
$ file /lib/x86_64-linux-gnu/ld-2.28.so
/lib/x86_64-linux-gnu/ld-2.28.so: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=f25dfd7b95be4ba386fd71080accae8c0732b711, stripped


2 Answers 2


I spent one day on this and of course 1 second after posting this question I remembered something like this existed to register .exe files for wine:

$ sudo cat /proc/sys/fs/binfmt_misc/wine 
interpreter /usr/bin/wine
extension .exe

and /usr/bin/wine did not exist.

I got rid of it using:

$ sudo update-binfmts --remove wine /usr/bin/wine
update-binfmts: warning: no executable /usr/bin/wine found, but continuing anyway as you request

and it works now

  • Ugh; why doesn't that work by recognizing MZ ... PE headers?
    – Joshua
    May 5, 2021 at 19:51

Most UN*Xes, including Linux, recognize native executable files (ELF files, in the case of most modern UN*Xes, including Linux) by a "magic number" that appears at or near the beginning of the file.

Windows binaries are in the Portable Executable format, which also has magic numbers - the file begins with a stub MS-DOS executable, which begins with a magic number containing the letters "MZ", and also has a separate "PE" magic number, at a variable offset.

According to the kernel.org documentation for binfmt_misc, a binfmt_misc rule can be based on the file contents - for example, looking for a magic number - rather than on the file extension. The example rule they give for Wine is


As you don't have Wine installed, removing the rule entirely is the right fix. If you ever install Wine and do want to be able to run Windows binaries in the same way that Linux binaries can be run, you should use a rule like the example rule, rather than a rule telling the kernel to assume anything ending with .exe is a Windows executable.

  • to be honest I don't remember if I configured the binfmt_misc rule in the past myself or if it came with some package or something, anyway thanks for adding useful info to the answer
    – premek.v
    May 4, 2021 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.