Guide to Installing Dotnet-SDK on Linux Systems

How To Install .NET SDK On Linux

Looking to install Dotnet-SDK on your cloud instances or on your personal computers to deploy a .NET application? Well then follow this guide to learn more about Dotnet and how to install it on Linux. So let’s get started.

To install Dotnet-SDK on Linux, you can use the default package manager for your distro or opt for Snap. For Ubuntu/Debian, use sudo apt-get install dotnet-sdk-7.0. For RHEL and Fedora, the command is sudo dnf install dotnet-sdk-7.0. Snap users can install it with sudo snap install dotnet-sdk-7.0. Always check the Dotnet version compatibility with your Linux distro before proceeding.

Understanding Dotnet-SDK: Your Gateway to Cross-Platform Development

Build applications for Windows, Linux, macOS, iOS, Android, and much more. The .NET framework provides you with that platform for software development. I would like to believe that once in our life we must have installed games and might have seen errors like .dll missing.

Well, guess what it is actually an assembly file that stores the compiled code written in C#, F#, or Visual basic programming language for .NET application. The code is usually compiled into a language-agnostic Common Intermediate Language(CIL). So when the app run, the Common Language Runtime(CLR) takes the assembly and uses a just-in-time(JIT) to turn it into a machine code to run it on a computer.

All this was too technical but if you are looking to know more about it, then you can look it up on their website.

I will not delve too deep into it, though I just want to mention C# is used a lot in .NET so if you are a beginner get ready to see a lot of codes in C#. For those who don’t know about this language, it’s essentially C with Object-Oriented Programming features.

So let’s see now how to install it on your Linux distros.

Installing Dotnet-SDK on Various Linux Distros

Dotnet-SDK is widely adopted in enterprise settings, especially on Linux cloud infrastructures and so is Linux(especially on cloud infrastructures) hence the probability of finding your distro supporting .NET is pretty high. I am going to show how to install Ubuntu, RHEL, and Fedora and also how to use Snap to install Dotnet.

Using Default Package Managers for Dotnet-SDK Installation

Most distros have their own package managers and usually, people prefer that compared to Snap and Flatpak(due to bloat). So let’s see how to install it using the default package manager of your distro.

For those who are using Ubuntu/Debian, run the below command to install it.

sudo apt install dotnet-sdk-7.0

If you want ASP.NET Core runtime then run this command also.

sudo dnf install aspnetcore-runtime-7.0

Though just a reminder to go on their website and see what version of Dotnet is supported on your distro. For Ubuntu >= 18.04, both the 7.0 and 6.0 is available. For Debian versions 10, 11, and 12 versions 7 and 6 are available.

If you are using RHEL 9 OR 8, then you are in luck, Dotnet version 7 and 6 are supported. RHEL is mostly used by industries so be careful to check the version of your OS before you install Dotnet(Don’t want anything to break in production, lol). Run the below command to install it in RHEL

sudo dnf install dotnet-sdk-7.0
sudo dnf install aspnetcore-runtime-7.0

For Fedora 38 and 37, the latest version of Dotnet is supported and you can download it by using the same commands as RHEL(well they have the same color hat on, i.e. Red).

For Arch users, I will recommend reading this wiki .NET, it tells how to install manually or use AUR.

Installing Dotnet-SDK with Snap

Before we use Snap to install, first make sure you have it installed in your system. To know about Snap refer to this article on Snaps in Linux: A Basic Introduction.

Once Installed you can run the below command to see the Dotnet version available on Snap.

snap info dotnet-sdk
Dotenet On Snap
Dotenet On Snap

As you can see, you have a lot of options, of course, whether your OS will support it or not is a different thing, but c’mon we are Linux users, and nobody takes our freedom away, so go for what you want.

To install the 7.0 version run the below command.

sudo snap install dotnet-sdk-7.0

With this you should have Dotnet installed in your system, I have never used Dotnet, so if there is someone who is a beginner like me, I will recommend you to check the next section.

Quick Dotnet-SDK Demonstration: Your First Hello World App

For this demonstration, I and just going to print Hello World in the console(nothing too big), and you can find it on the official docs in tutorials.

I am making a console app, you can go for web or mobile as your first one but I am just a beginner and just wanted to get a feel of it. As talked before Dotnet supports C# so an understanding of C# is required.

I don’t know much about C# but I have used it before for building games using Unity(those were days, trying everything, guess too old for that now).

Run the below command in your terminal to create a .NET application.

dotnet new console -o MyApp -f net7.0

This will create a template console app with all the required files present in the folder MyApp. Inside the MyApp folder, you will find MyApp.csproj, obj and Program.cs. The file that you will be working with is Program.cs. By default, it has the following code already written in it.

// See for more information
Console.WriteLine("Hello, World!");

Well, there you go, here is your Hello World console app but let’s write something more, to feel like we did something. Append the below line in the Program.cs file. You can use Vim to open the file and add this statement.

By the way, you might like this article on Guide to Installing Neovim on Linux: Explore the Modern Vim

Console.WriteLine("The current time is " + DateTime.Now);

Once done, save it and then run the below command to see the output.

dotnet run

Wrapping Up: What’s Next in Your Dotnet-SDK Journey?

With this we have come to the end of this article, we learned about .NET and we saw how to install it on Linux. It is used a lot in industries and in fact, you will find it being installed on cloud instances before we deploy .NET applications.

Majory we use C# as the programming language but it also supports F# and Visual Basic. You’re now equipped to kickstart your Dotnet-SDK journey on Linux. What will you build first?