Executable File

Share

What is an Executable File?

An executable file is a file that contains an algorithm for your computer to execute, e.g. the data of the file is the data of a program that will be executed by the CPU. When we "open" an executable file, for example by double clicking on it, the program contained within is started.

Types and File Extensions

On Windows, the file extension of an executable file is typically .exe. This is used by all sorts of applications. When you double click on a .exe file, the operating system starts the program contained within the file. .exe files have a unique characteristic on Windows: normally, the icon of a file displayed in a file manager is defined by its file type, such that all files of the same type have the same icon, but an .exe file may define its own custom icon.

Danger: one common way to trick people into opening a virus thinking it's a normal file is to make its icon look like the icon of a common file type. For example, a virus can have an icon that makes it look like a random video file or music file. It's a good idea to check the file extension of a file, and familiarize yourself with them, to avoid falling for such tricks.

Some installers on Windows may have a .msi extension instead.

A batch script is a source code file containing a batch of commands to be executed in a terminal window. It has the .bat extension.

Applications created with Java may be distributed as .jar files that require the Java runtime to be executed. Although they are uncommon today, games made with Macromedia Flash used to be distributed with a .swf extension.

Some programs are contained in non-executable files. For example, a .dll file contains various small programs but no entry point, so it can't be started. This is called a library. These libraries are used by executable files that depend on these small programs for their functions, e.g. libpng.dll is a library to load PNG files.

On Linux, executable files typically have no extension if they are installed directly into the system. Some exceptions exist.

Programs made with C#, that require the .NET runtime, normally have a .exe extension even when they are run on Linux.

Linux has two portable formats for applications, Appimages and Flatpaks, their extensions being .appimage and .flatpak, respectively.

The batch script equivalent on Linux is a shell script, and typically has a .sh extension.

Scripts can be written in any scripting language, such as Python (.py), Ruby (.rb), etc. Although scripts are often considered executable on Linux, they're not considered executable files on Windows due to differences in the culture of users. On Linux, many users are developers experienced with programming, so you're expected to know how the system works on some technical level. On Windows, the average user isn't familiar with such technicalities, so "executable file" is largely limited to .exe files you can double click on.

On Linux, a file may only be executed if the file permissions say the user may execute it (X in RWX notation). This means that even if you have an .appimage file, you can't double click to run it unless you mark it as an executable file first. This prevents the issue of accidentally running a new program (and potentially a virus) when you just wanted to open a file in a program you already had installed in your system.

Native Executables

Although there are many types of executable files, not all of them are equal. Every system has one type of executable that is "native" of the system. In this case, when you "open" the executable file, a program that is part of the system will load the executable file in the RAM memory and set it up so that the CPU can start executing it.

A non-native program needs some third-party program to be installed in order to function. In the case of a Java program, this third-party program is the Java runtime. So the Java runtime is a native program, and after it's loaded by the system, the runtime handles executing the executable file. In the case of a Python script, the third-party program is the Python interpreter.

We can also say that batch and shell scripts are not native because they are interpreted code. A native program is compiled to machine code, which is the code that is understood by the physical CPU itself. This means that you can't take a program compiled for a CPU with x86 architecture and make a CPU with ARM architecture run it, because the machine code for x86 is different from the machine code for ARM. Scripts can run on any architecture because they will be interpreted by an interpreter that is a native executable.

Written by Noel Santos.

About the Author

I'm a self-taught Brazilian programmer graduated in IT from a FATEC. In a world of increasingly complex and essential computers, I decided to use my technical expertise in hardware, desktop applications, and web technologies to create an informative resource to make PC's easier to understand.

View Comments