How to install Mono on Ubuntu 20.04?

Mono can also be installed on Ubuntu 20.04 This language that is very popular among many developers is now available for Ubuntu and in this post, we will show you how to install it in a few quick steps.

What is Mono?

According to the project website:

Mono is an open-source development platform based on the .NET Framework. It allows developers to build cross-platform applications with improved developer productivity. Mono’s .NET implementation is based on the ECMA standards for C# and the Common Language Infrastructure.

With Mono we can create multiplatform applications quickly, using databases such as Mysql, Postgresql, and others. All this with C# as the basis of the project.

It is now possible to install it on Ubuntu which further increases the possibilities of the language and the project. In addition to this, many developers use it for small applications where speed or solving a specific problem prevails.

The above is proven by a large amount of documentation available through blogs and other forums.

Install Mono on Ubuntu 20.04

As expected, Mono is not included in the Ubuntu 20.04 repositories, so we have to resort to the repository provided by Mono to install it.

So, open a terminal from the main menu

Now, install some packages needed for the tutorial.

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

These packages will allow us to add the Mono repository to the system.

The next step is to add the GPG key of the repository to the system.

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

Sample Output:

Executing: /tmp/apt-key-gpghome.fde4Y7IXaz/ – keyserver hkp:// – recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
gpg: key A6A19B38D3D831EF: public key "Xamarin Public Jenkins (auto-signing) <[email protected]>" imported
gpg: Total number processed: 1
gpg:               imported: 1

After that, add the Mono repository by running the following command:

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

Then, you can install Mono with a meta-package called mono-complete which installs all the Mono components needed to have a complete Ubuntu experience.

sudo apt install mono-complete

When the process is finished you will be able to check the installed version to see how the command works:

mono – version

Sample Output:

Mono JIT compiler version (tarball Mon Feb 22 17:33:28 UTC 2021)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors.
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	Interpreter:   yes
	LLVM:          yes(610)
	Suspend:       hybrid
	GC:            sgen (concurrent by default)

Creating a Hello World file

The best way to check if everything is in order is to create a new file where we can add some code and compile it.

So, with the text editor of your choice, I will use nano, create a file called helloworld.cs, and add the following.

nano helloworld.cs
using System;
 public class HelloWorld
     public static void Main(string[] args)
         Console.WriteLine ("Hello World. Welcome to atechtown");

Then, compile the file:

csc helloworld.cs

And run it using the following command:

mono helloworld.exe


Hello World. Welcome to atechtown

This tells us that the whole process was successful


Mono is a project that can be used to make cross-platform applications and with the support of Microsoft, we can have an idea of its seriousness. Installing it is not a complex process and it is within everyone’s reach.

Share This: