How to install and use Mono on Ubuntu

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"


Mono is the OpenSource implementation of the Microsoft .NET software stack. It is based on ECMA/ISO standards and implements the C# programming language and the Common Language Runtime. To find out more about Mono, have a look at the Mono project website.

Installing Mono on Ubuntu 21.04

By default, the Mono application is not found in the Ubuntu systems. To install Mono from the official repository follow the steps given below:

1: Installing the dependencies

Let’s start off by adding new repositories over HTTPS.To do so, first update the apt repository using:

$ sudo apt update

In addition to, install the apt dependencies for mono by using the command:

$ sudo apt install dirmngr gnupg apt-transport-https ca-certificates software-properties-common

2: Importing GPC Key

So After adding the repository users are required to extract the key and place it on the Ubuntu server.

$ sudo apt-key adv --keyserver hkp:// --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF

This way users can easily import the GPC key. The output will look like the one displayed above.

3: Adding Mono repository

Now, to add the mono repository to the source’s list of the system, append the following command in the terminal window:

$ sudo apt-add-repository 'deb stable-focal main'

4: Installing Mono

Once you have installed all dependencies of Mono, the next step is to install Mono.We will be installing mono-complete package.

$ sudo apt install mono-complete

So The Mono runtime along with relevant tools and libraries will be installed successfully.

Verifying the Mono installation

Type the following command in the terminal window to verify mono was installed:

$ mono --version

In addition to The installed Mono version displayed in the output.The latest version of Mono available at the time of download was This version might vary at the time of your download.

Create a program in Mono

I’ll show you how to create a small C# ‘We love unixcop’ program to test our Mono installation.Let’s create a .cs file and then save it under the name unixcop.cs

1. Save your C# code in a file called unixcop.cs

code is:

using System;

namespace Project_1 {
    class MainClass {
        public static void Main (string[] args) {
            Console.WriteLine ("We love Unixcop!");
            Console.ReadKey ();

2. Make unixcop.cs executable. Right-click the unixcop.cs file -> select Properties -> Permissions tab -> put a check mark to the left of Allow executing file as program as shown.

3. Change directories using the cd command to the directory that contains the unixcop.cs file.

4. Use the mcs compiler and create a Windows executable named unixcop.exe from the source unixcop.cs.

$ mcs -out:unixcop.exe unixcop.cs

5. Run the unixcop.exe program with mono.

$ mono unixcop.exe


In this article, we saw how to install Mono on an Ubuntu 21.04 system in detail. We then verified the installation of the application and wrote a small unixcop script to test the Mono C# compiler.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"
unixcop Admin


Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook