How to install Mono on Debian 11

Software frameworks that operate behind the scenes are helpful in their own way. People utilize such frameworks for developing applications without starting from scratch. Just Like .NET, Mono comes under the category of these kinds of frameworks.

Mono is compatible with Linux, Mac and Windows operating systems. It started as an open-source Linux implementation of the .NET framework. Mono evolved into something more when its developers announced that it provides support to various operating systems.

Mono is built around the C# programming language, which is noted for its portability. For instance, the Unity game engine utilized the C# for creating cross-platform video games. This is only possible because of the design of the C# language. This language can be converted into Common Intermediate Language (CLI), which is then executed in a Virtual Machine or compiled to a native code; similar to the .NET framework, Mono permits you to compile and run C# programs. You can also employ this framework in your Linux-based system, such as Debian 11.

In this write-up, we will demonstrate to you how to install Mono on Debian 11. After that, you will check out the method of using Mono on Debian 11 in the last section of the post. So, let’s start!

How to install Mono on Debian 11

First of all, update the repositories of the Debian 11 system:

$ sudo apt update

Now, we will install the packages required for the Mono installation:

$ sudo apt install dirmngr gnupg apt-transport-https ca-certificates

Now, utilize the below-given command for importing the GPG key from the Mono repository:

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

The output declares that the GPG key of the Mono repository is imported to our Debian 11 system:

In the next step, we will add the Mono repository to the source list of our system:

$ sudo sh -c 'echo "deb stable-bullseye main" > /etc/apt/sources.list.d/mono-official-stable.list'

At this point, we have installed all of the required packages for Mono installation and also added the Mono repository. Now, before installing Mono, we will again update our system repositories:

$ sudo apt update

Once you update the packages list, write out the below-given command for installing Mono on your Debian 11 system:

$ sudo apt install mono-complete 

Wait for few minutes, as the installation procedure for Mono will take some time:

The above-given error-free output signifies that Mono is installed successfully. Now to confirm this information, check out the Mono version on your system:

$ mono --version

Till this point, if you have correctly followed the steps of Mono installation, then you can move ahead with us to the next section.

How to use Mono on Debian 11 system

In this section, we will teach how you can use Mono for building a simple program. For this purpose, we will open up the nano editor and create a “testfile.cs”:

$ sudo nano testfile.cs

Now, add the following code in the opened “testfile.cs”:

using System;
public class TestFile  
    public static void Main(string[] args)
        Console.WriteLine ("THIS IS A SAMPLE TEST FILE");

Next, press “CTRL+O” for saving the code you have added in the “testfile.cs”:

Now, utilize the Mono C# Compiler “mcs” for building an executable file for “testfile.cs”:

$ mcs testfile.cs

To execute the “testfile.exe” with Mono, write out the provided command in your Debian 11 terminal:

$ mono testfile.exe

According to the added code in the “testfile”, you will see a “THIS IS A SAMPLE TEST FILE” line on your Debian 11 terminal:


Mono is the open-source Linux implementation of the .NET Framework. It is utilized in the various operating systems such as Linux, Windows, macOS for building cross-platform applications. You can use this platform for compiling and running C# programs. In today’s write-up, we have shown you how to install Mono on Debian 11. Moreover, a practical example of executing a C# program with Mono is also demonstrated in this post.