Mono is a platform for developing and running cross-platform applications based on ECMA/ISO Standards. It is a free and open-source implementation of the Microsoft .NET framework.
This tutorial explains how to install Mono on Rocky Linux 8 and CentOS 8 or AlmaLinux 8
Precondition
The instructions assume that you are logged in as root or a privileged user sudo
.
Install Mono on Rocky Linux 8 and CentOS 8
The easiest and recommended way to install Mono on debian 10 is to install it directly from the Mono repository. This is a relatively easy process and will only take a few minutes.
1) Import the GPG key from the repository using the following command:
sudo rpm --import 'http://pool.sks-keyservers.net/pks/lookup?op=get&search=0x3fa7e0328081bff6a14da29aa6a19b38d3d831ef'
2) Add the Mono repository to your system by running the command below:
dnf config-manager --add-repo https://download.mono-project.com/repo/centos8-stable.repo
The output will look like the following:
Adding repo from: https://download.mono-project.com/repo/centos8-stable.repo
3) Once the repository is enabled, install Mono with:
sudo dnf install mono-complete
mono-complete
is all the meta-packages you need for mono development, mono-complete will install the Mono runtime, development tools and all mono libraries.
4) Verify the installation by typing the following command, which will print the Mono version:
mono --version
At the time of writing this article, the latest stable version of Mono is 6.12.0 Stable (6.12.0.122).
Mono JIT compiler version 6.12.0.122 (tarball Tue Feb 4 19:28:42 UTC 2021) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS: __thread SIGSEGV: altstack Notifications: epoll Architecture: amd64 Disabled: none Misc: softdebug Interpreter: yes LLVM: yes(610) Suspend: hybrid GC: sgen (concurrent by default)
At this point, you have successfully installed Mono on Rocky Linux 8 and CentOS 8, and you can start using it.
Start Mono with Hello World on Rocky Linux
To verify that everything is set up correctly, we will create a program that will print the classic “hello world” message.
Open the text editor nano
and create a file named hello.cs with the following content:
nano hello.cs
using System; public class HelloWorld { public static void Main(string[] args) { Console.WriteLine ("Hello World!"); } }
use csc
to build the program:
csc hello.cs
The above command will build an executable named hello.exe
.
Run the executable using the command below:
mono hello.exe
The output will look like this:
Hello, World
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 :
chmod +x hello.exe
You can now run the file hello.exe
by typing:
./hello.exe
Conclusion
Today we learned how to install mono on rocky Linux 8 and CentOS 8 as well as AlmaLinux 8 also follows same processes, The latest stable Mono release packages are available for installation from the official Mono package repositories.
Some Rocky Linux Related Tutorials :
How to Install Rocky Linux 8 Step-By-Step Guide with Screenshots
How to Add EPEL Repository on Rocky Linux, AlmaLinux and CentOS
Leave a Reply Cancel reply