Language: EN

instalar-net-6-en-un-ordenador-con-linux-ubuntu

Install .NET 6 on a computer with Linux (Ubuntu)

In this post we will see how to install .NET 6 on a computer with Linux, and we will learn how to create and run applications in C#.

As we saw in this post, one of the advantages of .NET 6 is that it has been a major step forward in terms of convergence. Thus, it is now possible to run .NET applications on a wide variety of architectures and operating systems.

Today, we will learn to use .NET 6 on a Debian-based distribution. Personally, I am going to use Linux Mint, but it should work with the main Debian-based Linux distros, such as the popular Ubuntu.

Installation with APT

If we do not want to use the Snap manager, we can also use APT to install .NET. To do this, first we add the Microsoft package signature key to the list of trusted keys and add the package repository by doing,

wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb

Then, we can use APT to install .NET 6, running the following commands,

sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y aspnetcore-runtime-6.0

Installation through Snap

The easiest way to install dotnet is through the Snap package manager. This comes installed by default in several distros, including Ubuntu. In case your distribution does not have it installed, you can do it simply by,

sudo apt update
sudo apt install snapd

sudo snap alias dotnet-sdk.dotnet dotnet With Snap already installed on our computer, the installation of .NET can be done simply by,

sudo snap install dotnet-sdk --classic

Check the installation

To check that the installation has been done correctly, we run the following command,

dotnet --version

If everything has been installed correctly, we should see the installed version of .NET.

linux-dotnet6-version

From here, we can start developing in .NET on Linux, for which I recommend starting with a simple tutorial like the one we saw in this post.