Designed primarily for business and financial applications, COBOL is a high-level programming language that has been widely used for over 60 years. With its simple and self-explanatory syntax, COBOL makes it easy to write, read, and maintain large-scale business applications.
Although new languages like Java and C# are gaining popularity, COBOL still dominates critical enterprise systems, especially in the financial, governmental, and insurance sectors. Recent surveys estimate that there are still over 200 billion lines of COBOL code in use today.
The good news is that COBOL can run on modern operating systems like Linux. Here‘s an in-depth guide on how to set up a Linux environment for running COBOL programs.
Installing a COBOL Compiler on Linux
The first step is to install a COBOL compiler on your Linux system. The most commonly used open-source COBOL compiler is GnuCOBOL.
To install GnuCOBOL on a Debian/Ubuntu system, run:
sudo apt update
sudo apt install open-cobol
For RHEL/CentOS systems, enable the EPEL repository first:
sudo yum install epel-release
sudo yum install open-cobol
This will install the latest version of GnuCOBOL along with any required dependencies.
Structure of a COBOL Program
Before we run some COBOL programs on Linux, let‘s quickly go through the basic structure of a COBOL program.
Every COBOL program is divided into four main divisions:
- Identification Division – Provides meta information about the program
- Environment Division – Configures external settings
- Data Division – Defines data structures
- Procedure Division – Holds the executable logic
Here‘s a simple "Hello World" program example:
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY "Hello World!".
STOP RUN.
This program prints "Hello World!" when executed. The Identification Division names the program and the Procedure Division contains the print statement.
Compiling and Running COBOL Programs
To compile a COBOL program on Linux, use the cobc command that came with the compiler installation:
cobc -x hello-world.cob -o hello-world
This will compile hello-world.cob into an executable called hello-world.
Next, simply execute the generated program:
./hello-world
This will print "Hello World!" on your terminal.
Similarly, you can compile and run other COBOL programs on Linux.
Here are a few things to note about running COBOL programs:
- By default, input and output are from standard streams.
- COBOL programs have to be explicitly ended with
STOP RUN. - Compile with
-fverbose-outputflag to see detailed compilation steps.
Calling COBOL Programs from Other Languages
COBOL provides interfacing capabilities to call COBOL programs from other languages like C/C++, Java, Python etc.
This allows you to leverage existing COBOL business logic in modern applications.
Here‘s an example of calling the above COBOL program from C:
#include <stdio.h>
extern void HELLO_WORLD();
int main() {
HELLO_WORLD();
return 0;
}
The external COBOL program can be compiled to a shared library and dynamically loaded from C.
Similarly, COBOL provides native interoperability with other languages, enabling two-way communication.
This allows you to reuse legacy COBOL systems on modern infrastructure.
Migrating COBOL to Linux
For organizations running enterprise COBOL applications built decades ago, migrating to Linux can be challenging.
Here are some best practices for ensuring a smooth migration:
Code Conversion – Use automated tools to convert COBOL code from legacy platforms to be Linux-compatible.
Data Migration – Transfer application data to Linux data stores like RDBMS or NoSQL databases.
Integration – Modernize interfaces using web services and APIs for integration.
Testing – Rigorously test the entire application functionality on Linux.
Training – Train developers on Linux tools, processes, and monitoring required for COBOL.
With careful planning and execution, COBOL systems can be migrated to reap the cost and performance benefits of running on Linux.
Conclusion
COBOL may be an old language, but it continues to support critical business systems built over decades. With some configuration, COBOL can run on modern Linux platforms while maintaining compatibility with legacy environments.
Whether you‘re maintaining existing COBOL systems or integrating COBOL with latest technologies, Linux provides the ideal platform for running both old and new applications effectively.
So don‘t be afraid to try running COBOL programs on Linux – you might be surprised at how well they perform!


