Install and Configure Mono on Rocky Linux 8

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.

You can now proceed to the following steps on the Orcacore website to set up Mono on Rocky Linux 8.

How To Install and Configure 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'
Add Mono Repository

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:

Install Mono on Rocky Linux 8

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.exeby 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.

Share your love

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!