1

I know a lot of answers have been written about this but they all seem to be about how every file in Linux (even text files) are executable.

What I want is to compile code into machine code similar to a Windows .exe so that no one can tamper with my code. I'm not interested in interpreters either. Is there a straightforward answer to this?

Zanna
  • 72,312

1 Answers1

3

In simple terms, what you are looking to create is a binary file, one that does not store text but is essentially a list of instructions to the Linux kernel to execute some kind of program.

Typically, these files are created by a program called a compiler. Common examples of programming languages where code is compiled to create binary executables include C, C++, and Fortran. gcc and gfortran are the corresponding programs that can turn your code into a binary executable. While it is possible to create a binary file from Python, this is not the norm.

In Linux any file can be marked as an "executable" and unlike Windows, the file extension has no bearing on its executability or its content (i.e. whether it is a binary or text file, or whether it contains C or Python code) although it can serve as a reminder. The command chmod allows you to change the read, write and execute permissions of a file with any extension. When you compile code with gcc or gfortran on a typical Linux system, it will automatically be marked as executable.

rviertel
  • 759