How To Install Mono on Debian 11

Install Mono on Debian 11

In this article, we will have explained the necessary steps to install Mono on Debian 11. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Mono is an open-source implementation of Microsoft’s .NET Framework based on the ECMA standards for C# and the Common Language Runtime. Mono is most popularly used for developing cross-platform tools and applications integrated with .NET technologies.

Install Mono on Debian 11

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo apt update
sudo apt upgrade
sudo apt install gnupg dirmngr apt-transport-https ca-certificates

Step 2. Install Mono on Debian system.

Now add the Mono repository to your system sources’ list:

sudo sh -c 'echo "deb https://download.mono-project.com/repo/debian stable-buster main" > /etc/apt/sources.list.d/mono-official-stable.list'

Then, import the repository’s GPG key:

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

As all the dependencies have been installed and the APT repository is updated, now run the installation:

sudo apt update
sudo apt install mono-complete

We verify the installation of the mono version by typing the below-given command:

mono --version

Step 3. Create Simple Mono Application.

Now create a simple Mono application, open your favorite text editor, and create a new file with the name hello.cs:

sudo nano hello.cs

Add the following lines of code:

using System;

public class HelloWorld
{
public static void Main(string[] args)
{
Console.WriteLine ("Hello World!");
}
}

Use the csc compiler to build the program:

mono-csc hello.cs

Next, run the executable using the command below:

mono hello.exe

That’s all you need to do to install the Mono on Debian (Bullseye). I hope you find this quick tip helpful. For further reading Mono on Debian’s system, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.