Executable files in Windows and Linux


Windows (.EXE)

In the field of computer, OS natively using this format are DOS, Microsoft Windows, OS/2 and ReactOS. The format of EXE files was introduced in March 1983 in version 2.0 of MS-DOS and is still used today in the versions of Microsoft Windows, Windows Vista, Windows 7, Windows 8 Windows 8.1 and Windows 10.

Format

The EXE files consist of a header followed by segments defined in the source code. The header data are used by the operating system to perform necessary for the proper functioning of the program initializations, although this structure is not part of the final image of the program in memory.

Programming

There are two ways to create an EXE file type. One is using a compiler that can create this type of file. The other way is by joining an Assembler language source code and then linking the object code resulting from the previous task. Outside the scope of the program there are also programs that generate executable EXE for specific tasks. Examples of these are the compressor WinZip, Microsoft Powerpoint and the Adobe Flash.

Compiling and linking Assembler

Compiling is the process by which a named set of source code to object code is translated. Normally the term compiled is referred to the task of compiling together the linking process, since most (if not all) of the compilers perform default both tasks together, unless specified to be only get the object code.

Linux

It is very common for those who are migrating from Windows arises doubt how to identify the executable file of an application. Of course, in the Windows directory and file structure it is completely different from Linux. In Windows (XP) almost all programs are under "Program Files" folder, the operating system is in its own folder "Windows" and storage is done on drive C: . In Linux, the distribution of the operating system and applications have a very different organization. There is no drive (C:) as a concept. Everything emerges from a "tree" whose root directory is precisely root (/).

But how to recognize a program or an executable file?

In linux, almost any file can be executable . Let's do a little test. Let's open a terminal and let ´s run the following command:

$ ls -la /usr/bin/fil*
-rwxr-xr-x 1 root root  15036 mar 11 05:57 /usr/bin/file
-rwxr-xr-x 1 root root 380324 jul  1 15:32 /usr/bin/file-roller

The "x" attribute means tha the file is executable.

Types of executables

An executable can be ELF or script type. To find out what type of file is write the "file" command:

$ file /usr/bin/file
/usr/bin/file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped

We see the same command file is recognized itself as an executable ELF 32-bit type.

Scripts

The Bourne-Again Shell (bash), Shell (sh) and Perl scripts (pl) have a header that tells the command file that file type is. If we view the contents of a script we surely would find a first line like this:

#!/Bin/bash

or in perl:

#! / usr/bin/perl

Conclusion

We saw that any file can be executable on linux but in Windows only .EXE (and formerly .COM) are executables. In Linux we may find a shell script, an ELF executable, the combination of scripts and files, etc. But most important is that always must first read the README file, either a package with source code tar.gz or even heading scripts, as there are many programmers offers their scripts with directions and instructions.