17

Can anyone distinguish the difference between binary file and .exe file?

slm
  • 369,824
user2720323
  • 3,589

3 Answers3

32

binary file is pretty much everything that is not plain text, that is contains data encoded in any different way than text encoding (ASCII, UTF-8, or any of other text encodings, e.g. ISO-8859-2). A text file may be a plaintext document, like a story or a letter, it can be a config file, or a data file - anyway, if you use a plain text editor to open it, the contents are readable. A binary is any file that is not a text file (nor "special" like fifo, directory, device etc.)

That may be a mp3 music. That may be a jpg image. That may be a compressed archive, or even a word processor document - while for practical purposes it's text, it is encoded (written on disk) as binary. You need a specific program to open it, to make sense of it - for a text editor the contents are a jumbled mess.

Now, in Linux you'll often hear "binaries" when referring to "binary executable files" - programs. This is because while sources of most programs (written in high-level languages) are plain text, compiled executables are binary. Since there are quite a few compiled formats (a.out, ELF, bytecode...) they are commonly called binaries instead of dwelling on what internal structure they have - from user's point of view they are pretty much the same.

Now, .exe is just another of these compiled formats - one common to MS Windows. It's just a kind of binaries, compiled and linked against Windows API.

SF.
  • 2,941
2

Batch files are really just text files, or small scripts which can be executed by command line processor - "cmd.exe", they where widely used in DOS environment for automation of common tasks.

EXE files are different from BAT files since they contain executable binary data rather than plain text commands. They are stored in the Portable Executable (PE) format. The EXE file format includes various headers and sections that tell Windows how to run a program. Some portions of an EXE file may contain program code while others may contain resource data.

David_DD
  • 121
0

Generally it can be said that there is no difference: in MS Windows OS executables have names *.exe, but in *nix-like OS executables can be named whatever you like and are called "binary files".

But it doesn't mean that every binary file is executable (like *.exe): binaries could be just a kind of information storages. For example, database files (such as MyISAM or InnoDB files for MySQL databases) are binary files too (but not executable).

AntonioK
  • 1,193