Install and Configure Mono on Rocky Linux 8 | Easy Steps
In this guide, we want to teach you How To Install and Configure Mono on Rocky Linux 8. Mono is a software platform designed to allow developers to easily create cross-platform applications as part of the .NET Foundation. Sponsored by Microsoft, Mono is an open-source implementation of Microsoft’s .NET Framework based on the ECMA standards for C# and the Common Language Runtime. This guide provides easy steps to get you up and running with Install and Configure Mono on Rocky Linux 8.
You can now proceed to the following steps on the Orcacore website to set up Mono on Rocky Linux 8.
To install MonoDevelop, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on Initial Server Setup with Rocky Linux 8.
1. Add Mono GPG Key and Repository
First, you need to import the GPG keys for Mono with the following command:
rpmkeys --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
Then, you need to add the Mono repository on Rocky Linux 8 with the command below:
su -c 'curl https://download.mono-project.com/repo/centos8-stable.repo | tee /etc/yum.repos.d/mono-centos8-stable.repo'

Next, you need to update your local package index with the following command:
sudo dnf update -y
2. Install Mono on Rocky Linux 8
At this point, you can use the following command to install Mono on your server:
sudo dnf install mono-complete -y
The package mono-complete should be installed to install everything – this should cover most cases of “assembly not found” errors.
You can verify your Mono installation by checking its version:
mono --version
In your output, you will see:

At this point, you have successfully installed Mono on Rocky Linux 8, you can start using it.
3. Create a Test Program with Mono on Rocky Linux 8
To verify that everything is set up correctly, we will create a program that will print the classic “hello world” message.
First, create a file named hello.cs with your favorite text editor, here we use vi:
sudo vi hello.cs
Add the following content to the file:
using System;
public class HelloWorld
{
public static void Main(string[] args)
{
Console.WriteLine ("Hello World!");
}
}
Use CSC to build the program:
sudo csc hello.cs
**Output**
Microsoft (R) Visual C# Compiler version 3.6.0-4.20224.5 (ec77c100)
Copyright (C) Microsoft Corporation. All rights reserved.
This command will build an executable named hello.exe
.
Run the executable file with the following command:
sudo mono hello.exe
In your output, you will see:
**Output**
Hello World!
Note: If you want to run a program by simply typing its name, you must set a flag to make it executable with the chmod command :
sudo chmod +x hello.exe
You can now run the file hello.exe
by typing:
sudo ./hello.exe
Conclusion
Installing Mono on Rocky Linux 8 is a straightforward process that enables you to run and develop .NET applications on a Linux environment. By adding the official Mono repository, updating your package lists, and installing the Mono runtime and development tools, you can ensure compatibility with a wide range of .NET applications. Once installed, Mono allows developers to build and execute cross-platform applications efficiently on Rocky Linux 8.
Hope you enjoy it. Please subscribe to us on Facebook and Twitter.
You may also like to read the following articles:
Install Python 3.13 on Rocky Linux
Installing GitLab on Rocky Linux 9
Reset MySQL Root Password on Rocky Linux
CheckMK Setup on Rocky Linux 9
FAQs
What is Mono?
Mono is an open-source implementation of the Microsoft .NET Framework that allows you to run and develop .NET applications on Linux and other platforms.
Is Mono compatible with .NET Framework applications?
Yes, Mono is compatible with many .NET Framework applications, especially those targeting older versions like .NET Framework 4.x. However, some advanced Windows-specific features may not be fully supported.
Alternative Installation Methods for Mono on Rocky Linux 8
While the above steps detail the standard method for installing Mono on Rocky Linux 8, there are alternative approaches you can take. These methods might be useful in specific scenarios, such as when you need a specific version of Mono, or prefer using containerization. Here are two different ways you can achieve the same goal:
1. Installing Mono via Snap Package
Snap is a package management system developed by Canonical (the creators of Ubuntu) that allows you to easily install and manage applications on various Linux distributions, including Rocky Linux 8. Using Snap provides a sandboxed environment for the Mono installation, potentially isolating it from other system dependencies and preventing conflicts.
Steps to Install Mono using Snap:
-
Enable EPEL Repository: If you don’t already have it, you’ll need to enable the Extra Packages for Enterprise Linux (EPEL) repository, as Snapd relies on it.
sudo dnf install epel-release -y
-
Install Snapd: Snapd is the service that enables the use of Snap packages. Install it with the following command:
sudo dnf install snapd -y
-
Enable Snapd Socket: Start and enable the snapd socket:
sudo systemctl enable --now snapd.socket
-
Ensure Snapd is Up-to-Date: It’s a good idea to refresh the Snapd installation:
sudo snap refresh
-
Install Mono Snap Package: Now you can install Mono using Snap. Use the following command:
sudo snap install mono
You can specify a channel (e.g.,
stable
,beta
,edge
) to install a specific version of Mono. For the stable version, the command would be simplysudo snap install mono
. -
Verify the Installation: Verify that Mono is installed correctly by checking its version. Since snap applications are installed in a sandboxed environment, you might need to call the command through snap:
snap run mono --version
Explanation:
This method simplifies the installation process and provides a degree of isolation. Snap packages are self-contained, meaning they include all the dependencies required to run the application. This eliminates potential dependency conflicts with other software on your system. However, Snap packages can sometimes be larger in size compared to traditional package installations.
2. Using Docker Container
Docker is a containerization platform that allows you to package applications and their dependencies into isolated containers. Using Docker, you can run Mono in a consistent and reproducible environment, regardless of the underlying operating system. This is particularly useful for development and deployment scenarios where consistency is paramount.
Steps to Run Mono in a Docker Container:
-
Install Docker: If Docker is not already installed on your Rocky Linux 8 system, install it using the following commands:
sudo dnf install docker -y sudo systemctl start docker sudo systemctl enable docker
-
Pull the Mono Docker Image: Pull the official Mono Docker image from Docker Hub. This image contains the Mono runtime and development tools.
sudo docker pull mono
-
Run the Mono Container: Run a container based on the Mono image. You can mount a local directory into the container to share code between your host system and the container.
sudo docker run -it --name mono-dev -v $(pwd):/app mono bash
-it
: Runs the container in interactive mode, allowing you to access a shell inside the container.--name mono-dev
: Assigns a name to the container (optional).-v $(pwd):/app
: Mounts the current directory ($(pwd)
) on your host system to the/app
directory inside the container. This allows you to edit your code on your host system and run it inside the container.mono
: Specifies the Docker image to use.bash
: Starts a bash shell within the container.
-
Compile and Run Your Code: Inside the Docker container’s bash shell, you can navigate to the
/app
directory (where your code is mounted) and compile and run your C# code. For example:cd /app csc hello.cs mono hello.exe
Code Example for Dockerized Application (hello.cs – same as before):
using System;
public class HelloWorld
{
public static void Main(string[] args)
{
Console.WriteLine ("Hello World from Docker!");
}
}
Explanation:
Docker provides a highly isolated and reproducible environment for running Mono applications. This eliminates dependency conflicts and ensures that your application behaves consistently across different environments. Docker containers are also lightweight and portable, making them ideal for microservices architectures and cloud deployments. The $(pwd)
ensures the current directory where the Docker command is run is linked to the container, simplifying file sharing.
These alternative installation methods offer flexibility depending on your specific requirements and preferences. Whether you choose the standard package installation, Snap packages, or Docker containers, you can successfully set up Mono on Rocky Linux 8 and start developing .NET applications.