In this guide, we want to show you to Install .Net (DotNet) Core on Rocky Linux 8.
.NET Core is the latest general-purpose development platform maintained by Microsoft. It works across different platforms and has been redesigned in a way that makes .NET fast, flexible, and modern. This happens to be one of the major contributions of Microsoft. Developers can now build Android, iOS, Linux, Mac, and Windows applications with .NET, all in Open Source.
Steps To Install .NET (DotNet) on Rocky Linux 8
To complete this guide, 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.
Install .NET (DotNet) on Rocky Linux 8
First, you need to update your local package index with the following command:
sudo dnf update -y
.NET packages are available in the default Rocky Linux repository.
You can install .Net tools, runtime, and SDK with the following command:
sudo dnf install dotnet
For installing only .NET Runtime, you can use the following command:
sudo dnf install dotnet-runtime-7.0
If you want to install the Net Software Development Kit (.Net SDK), you can use the command below:
sudo dnf install dotnet-sdk-7.0
Check Available Versions of Dotnet
Note: You can check what are the available versions to install with the command below:
sudo dnf search dotnet
When your installation is completed, you can verify your Dotnet (.NET) installation on Rocky Linux 8 by using the command below:
OS Name: rocky
OS Version: 8.7
OS Platform: Linux
Base Path: /usr/lib64/dotnet/sdk/7.0.102/
.NET SDKs installed:
.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.2 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.2 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
Now let’s see how to use the Dotnet (.NET) by creating a sample project on Rocky Linux.
Create a Sample Project with the .NET
First, you need to create a new console app with the following command, here we named it MyApp:
dotnet new console -o MyApp -f net7.0
The template "Console App" was created successfully.
Processing post-creation actions...
Determining projects to restore...
Restored /root/MyApp/MyApp.csproj (in 167 ms).
Then, switch to your project directory:
There is already a demo program inside the created project directory called
program.cs. To run the demo program, use the following command:
Uninstall .Net from Rocky Linux 8
If you don’t want to use “.NET” anymore, you can easily remove it with the command below:
sudo dnf remove dotnet
And for the SDK and runtime, you can use the following commands:
sudo dnf remove dotnet-sdk-your-version
sudo dnf remove dotnet-runtime-your-version
For example, if the version is 7.0 then the command will be:
sudo dnf remove dotnet-sdk-7.0
For more information, you can visit the .NET Documentation page.
At this point, you have learned to Install .NET (dotnet) on Rocky Linux 8.
Hope you enjoy it. You may be like these articles on the Orcacore website: