# How to Install Mono on Ubuntu 20.04?

{% embed url="<https://youtu.be/cWuTsjb63gA>" %}

### **Overview** <a href="#howtoinstallmonoonubuntu20.04-overview" id="howtoinstallmonoonubuntu20.04-overview"></a>

Mono is an open-source implementation of Microsoft's .NET Framework that allows you to run C# code on Linux. In this tutorial, we will focus on installing Mono on Ubuntu 20.04 and building a program with Mono.&#x20;

### Prerequisites <a href="#howtoinstallmonoonubuntu20.04-prerequisites" id="howtoinstallmonoonubuntu20.04-prerequisites"></a>

There are certain prerequisites that need to be met before you begin.&#x20;

* Ubuntu 22.04 LTS configured on your system.
* Non-root sudo user privileges.

### **Get Started** <a href="#howtoinstallmonoonubuntu20.04-getstarted" id="howtoinstallmonoonubuntu20.04-getstarted"></a>

**Step 1: Installing Mono**&#x20;

* Update the Ubuntu package index:

```
sudo apt update
```

![](http://customer.acecloudhosting.com/index.php?rp=/images/kb/1212_m1.png)

* Install the essential dependencies to incorporate a fresh repository via HTTPS:

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

* Add the Mono repository GPG key:&#x20;

```
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
```

![](http://customer.acecloudhosting.com/index.php?rp=/images/kb/1213_m2.png)

* Add the Mono repository to your system's sources list:

```
sudo apt-add-repository 'deb https://download.mono-project.com/repo/ubuntu stable-focal main'
```

* Install Mono by running the following command:

```
sudo apt install mono-complete
```

![](http://customer.acecloudhosting.com/index.php?rp=/images/kb/1214_m3.png)

* After the installation is complete, verify that Mono is installed by checking its version:&#x20;

```
mono --version
```

![](http://customer.acecloudhosting.com/index.php?rp=/images/kb/1215_m4.png)

**Step 2: Building a basic program with Mono**

* Open the nano text editor and create a new file with the extension '.*cs':*

```
nano program2.cs
```

![](http://customer.acecloudhosting.com/index.php?rp=/images/kb/1216_m5.png)

* Add the following code to the file:

```
using System;
 
public class WelcomeMono
 
{
      public statics void Main(string[] args)
      {
          Console.WriteLine ("Welcome to Mono!");
       }
 
}
```

Press CTRL + X to save and exit the file.

* Compile the program:&#x20;

```
csc program2.cs
```

![](http://customer.acecloudhosting.com/index.php?rp=/images/kb/1217_m6.png)

This command will compile the file program2.cs and create an executable file called program2.exe.&#x20;

* Run the program:

```
mono program2.exe
```

![](http://customer.acecloudhosting.com/index.php?rp=/images/kb/1218_m7.png)

### Conclusion <a href="#howtoinstallmonoonubuntu20.04-conclusion" id="howtoinstallmonoonubuntu20.04-conclusion"></a>

In this tutorial, you have successfully installed Mono, built and run a basic program with Mono on Ubuntu 20.04. You can now start developing C# applications on Linux.
