Running programs built for Microsoft’s framework on a Linux system is easier than you think. Mono is an open source framework that implements the C# language and compiles .NET tools to run on Unix platforms. It allows developers to run .NET applications on Linux servers.
This guide will show you how to install Mono on Ubuntu 18.04, compile a basic script, and manage your setup.
The default Ubuntu software sources may contain outdated versions of the framework. We will add the official repository to get the latest stable package.
First, install the secure connection certificates:
bashsudo apt install gnupg ca-certificates
Import the official GPG verification key:
bashsudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
Add the repository URL to your software list:
bashecho "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
Update your local packages to import the new metadata:
bashsudo apt update
Now we can install the framework packages. The complete package contains the runtime, standard libraries, and development compilers.
Install the complete bundle:
bashsudo apt install mono-complete
Verify that the installation was successful by checking the framework version:
bashmono --version
The output will display the Mono JIT compiler version number to confirm everything is set up.
Let us write a simple test application to confirm the compiler works properly.
Open a text editor and create a new C# file named hello.cs:
csharpusing System;class Hello { static void Main() { Console.WriteLine("Hello from Mono on Ubuntu!"); }} Save the file. Run the C# compiler to compile your script:
bashmcs hello.cs
The compiler will create an executable file named hello.exe in the same directory.
Run the executable program using the runtime:
bashmono hello.exe
The terminal will print the message from the program, showing that the system is configured correctly.
Adding the Mono package opens up several development possibilities:
You have successfully installed the Mono framework on your Ubuntu machine. You can now build and run C# programs. Leave a comment below if you have any questions or run into any compiler warnings.
Computer vision technology powers many modern applications, from image editors to facial scanners. OpenCV (Open Source Computer…
A remote desktop interface makes it easy to manage a remote computer. VNC (Virtual Network Computing) is…
Hosting your own code repositories is a great way to keep your projects private. Gitea is a…
Many modern programs require Java to run. From development tools like Eclipse to search systems…
Setting a static IP address on your server is a smart move. It ensures your…
Xrdp is an open-source implementation of the Microsoft Remote Desktop Protocol (RDP). It lets you access…