File Execution

Learn the difference between executable files in the Unix environment and Windows.

We'll cover the following

Windows vs Unix

Windows has strict rules for executable files. The file extension defines its type. The Windows loader runs only files with the EXE and COM extensions. These are the compiled executable programs. Besides these, we can run scripts. The script’s extension defines the interpreter that launches it. Windows cannot run the script if there is no installed interpreter for it. The possible extensions of the scripts are BAT, JS, PY, RB, and so on.

Unix’s rules for executing files differ from Windows’. Here, we can run any file if it has permission to read and execute. Its extension does not matter, unlike Windows. For example, the report.txt file is executable.

There is no convention for extensions of the executable files in Unix. Therefore, we cannot deduce a file type from its name. We use the file utility to get it. The command receives the file path on input and prints its type. Here is an example of calling file:

file /usr/bin/ls

Get hands-on with 1200+ tech skills courses.