Website Vidya
Cloud & DevOpsStep-by-Step Guide

How to Install Mono on Ubuntu 24.04

Learn how to install Mono on Ubuntu 24.04 LTS. Configure official APT repository, install mono-complete, and compile C# .NET applications on Linux.

RR
Rajesh RayLead Systems Educator
Published:
6 min read
PDF Cheat Sheet
How to Install Mono on Ubuntu 24.04
AI Executive SummaryWebsiteVidya AI

6 min read

Learn how to install Mono on Ubuntu 24.04 LTS. Configure official APT repository, install mono-complete, and compile C# .NET applications on Linux.

Key Highlights
  • Prerequisites and Supported Releases
  • Step 1: Updating System Packages and Installing Prerequisites
  • Step 2: Adding the Official Mono Project GPG Keyring
Grounded in full engineering runbookWebsiteVidya AI Engine

Mono is an open-source, cross-platform implementation of Microsoft's .NET Framework based on the ECMA standards for C# and the Common Language Runtime (CLR). Maintained under the .NET Foundation and sponsored by Microsoft, Mono enables developers to build and execute .NET applications, game server scripts (such as Unity), and enterprise tools natively across Linux, macOS, and BSD systems without rewriting legacy codebases.

While modern cross-platform development often targets .NET Core or .NET 8, Mono remains indispensable for legacy .NET Framework 4.x applications, Windows Forms porting, MonoDevelop workflows, and embedded development environments. Learning how to install mono on ubuntu 24.04 ensures that you have access to the full suite of Mono development libraries, runtime engines, and compilers.

In this step-by-step tutorial, we demonstrate how to configure the official Mono Project APT repository on Ubuntu 24.04 LTS (Noble Numbat) using secure GPG keyrings. We guide you through installing the comprehensive mono-complete meta-package, verifying your runtime environment, and compiling a multi-threaded C# test application.

Advertisement

Prerequisites and Supported Releases

This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat). The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.

Before proceeding, ensure you have the following requirements satisfied:

  • A server or workstation running Ubuntu 24.04 LTS with terminal access.
  • A non-root user account configured with sudo administrative privileges.
  • Basic familiarity with the command line and package management in Ubuntu.
  • An active internet connection to download deb packages from the official Mono repository.

Step 1: Updating System Packages and Installing Prerequisites

Before configuring third-party software repositories, update your local APT package database and install essential packages for secure repository communication.

Run the following command to update your system and install ca-certificates, curl, and gnupg.

Advertisement

These utilities allow APT to fetch cryptographic keys and verify package integrity over HTTPS connections.

# Update package lists and upgrade existing software
sudo apt update && sudo apt upgrade -y

# Install prerequisite security and networking utilities
sudo apt install -y ca-certificates curl gnupg

Step 2: Adding the Official Mono Project GPG Keyring

To verify the authenticity of Mono packages, import the official Mono Project GPG signing key.

Following modern Ubuntu 24.04 security standards, third-party GPG keys must be stored in de-armored format inside dedicated keyring directories at /etc/apt/keyrings rather than using deprecated commands like apt-key add.

Create the directory if it does not already exist, download the GPG key, de-armor it, and assign standard 0644 permissions.

Advertisement
# Ensure keyrings directory exists
sudo mkdir -p -m 0755 /etc/apt/keyrings

# Import the official Mono Project signing key
curl -fsSL https://download.mono-project.com/repo/xamarin.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/mono-official-vs.gpg

# Set correct read permissions
sudo chmod 0644 /etc/apt/keyrings/mono-official-vs.gpg

Step 3: Configuring the Mono APT Repository

With the signing key installed, add the official Mono repository source entry to your system's package sources list.

Create a new source file at /etc/apt/sources.list.d/mono-official-vs.list, explicitly referencing the GPG keyring file.

Then update your APT cache so that Ubuntu indexes all available Mono packages.

# Add Mono repository to APT sources
echo 'deb [signed-by=/etc/apt/keyrings/mono-official-vs.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main' | sudo tee /etc/apt/sources.list.d/mono-official-vs.list

# Refresh local package index
sudo apt update

Step 4: Installing Mono Packages

The Mono project provides several package options depending on your operational needs:

1. mono-complete: The recommended complete package. It installs the runtime, development tools, compilers (csc, fsc), Windows Forms libraries, ASP.NET components, and full class libraries.

2. mono-devel: A lighter development package containing the compiler and essential SDK libraries, ideal for CI/CD runners where full GUI components are unnecessary.

For maximum compatibility and ease of development, install the complete package using the command below.

# Install the complete Mono runtime and SDK suite
sudo apt install -y mono-complete

Step 5: Verifying the Mono Installation

Once the installation process completes, verify that the Mono runtime engine and C# compiler are accessible in your system path.

Run mono --version to inspect the active runtime version, JIT compiler architecture, and supported CLR specifications.

Also verify that the C# Roslyn compiler (csc) is present and ready to compile source code.

# Check Mono runtime version
mono --version

# Check C# compiler version
csc --version

Step 6: Building and Executing a Sample C# Application

To test your newly configured Mono development environment, create and compile a simple multi-threaded C# console application.

Create a project directory named ~/mono-demo and create a source file called Program.cs.

Write a simple C# program demonstrating basic I/O and task execution.

Compile the source code using the modern C# compiler (csc Program.cs) to produce a Program.exe managed assembly, and run it using the mono command.

// Create project folder and write Program.cs
mkdir -p ~/mono-demo && cd ~/mono-demo
cat <<'EOF' > Program.cs
using System;
using System.Threading.Tasks;

namespace MonoDemo
{
    class Program
    {
        static async Task Main(string[] args)
        {
            Console.WriteLine("Hello from Mono on Ubuntu 24.04 LTS!");
            Console.WriteLine($"CLR Version: {Environment.Version}");
            Console.WriteLine($"OS Platform: {Environment.OSVersion}");

            await Task.Delay(200);
            Console.WriteLine("Asynchronous task completed successfully.");
        }
    }
}
EOF

# Compile the C# program
csc Program.cs

# Execute the compiled assembly with Mono
mono Program.exe

Step 7: Installing NuGet Package Manager

Most real-world .NET applications depend on external libraries distributed through the NuGet package ecosystem. Mono includes a command-line client for NuGet.

Install the nuget CLI package using APT to enable package restoration and package publishing.

Verify the client by querying the official NuGet package index.

# Install NuGet package manager client
sudo apt install -y nuget

# Verify NuGet client version
nuget help

Step 8: Managing Mono Libraries and Troubleshooting

When running complex graphical applications or reporting services under Mono, you may occasionally need additional native rendering libraries.

If your application utilizes System.Drawing or Windows Forms, install the libgdiplus library to provide GDI+ rendering support on Linux.

Keep your Mono installation up to date by regularly applying standard system updates via sudo apt update && sudo apt upgrade.

# Install GDI+ rendering compatibility library for System.Drawing
sudo apt install -y libgdiplus

Troubleshooting and Common Errors

When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:

GPG signature verification error when updating APT

Resolution: Verify that the GPG key was saved in de-armored binary format inside /etc/apt/keyrings/mono-official-vs.gpg and that the repository line in /etc/apt/sources.list.d/mono-official-vs.list references the exact path with signed-by.

System.DllNotFoundException: Unable to load DLL 'gdiplus.dll'

Resolution: This error occurs when running WinForms or graphics applications without the GDI+ abstraction layer. Resolve it by installing the native Linux helper library: sudo apt install -y libgdiplus.

Compiler error: The type or namespace name 'System' could not be found

Resolution: This indicates that only mono-runtime is installed without full class libraries. Install the complete SDK by running sudo apt install -y mono-complete.

Security Best Practices and Hardening

Always import the official Mono Project GPG key from https://download.mono-project.com/ to ensure package authenticity.

Store GPG keyrings in /etc/apt/keyrings/ with 0644 permissions rather than using deprecated global keys.

Avoid running untrusted third-party .NET binaries with elevated sudo privileges under Mono.

Keep libgdiplus and core OpenSSL dependencies updated to safeguard network sockets against cryptographic CVE vulnerabilities.

Deepen your Linux system administration skills with our related production-tested guides:

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

3 FAQs
While modern greenfield applications should target .NET 8 or newer, Mono is essential for maintaining legacy .NET Framework 4.x applications, running Unity game server scripts, and supporting cross-platform tools built before .NET Core.
Yes, Mono includes an implementation of Windows Forms. Ensure you install libgdiplus so that GDI+ drawing operations render properly under X11.
You can uninstall Mono by running sudo apt purge -y mono-complete mono-devel mono-runtime && sudo apt autoremove -y && sudo rm -f /etc/apt/sources.list.d/mono-official-vs.list /etc/apt/keyrings/mono-official-vs.gpg.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Cloud & DevOps•

How to Close File Descriptors Above 9 in Dash Shell

Attempting to close a file descriptor above 9 in Dash using exec 10<&- results in a 10: not found error because Dash's POSIX lexer only recognizes single-digit file descriptors (0–9) in redirection operators. This guide explains the exact parser limitation, why FDs 10+ are reserved for internal shell state, and how to safely close inherited file descriptors using close_range, Python, or Perl wrappers.

RR
Rajesh Rai
Read More
Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout