How to Install .NET6, 7 or 8 in Ubuntu 22.04 | 20.04, Debian 12/11 & Other Linux

Ubuntu now support .NET officially. For other Linux, e.g., Debian, SUSE, Fedora, RHEL, this step by step beginner's guide may help!

Good news for Microsoft .NET developers and users! Ubuntu just added official support for .NET 6.0 & 7.0 in the current 22.04 LTS.

It’s the effort of both Microsoft and Canonical (the company behind Ubuntu). The 2 companies has set up a maintainer group for the development platform, to keep updating the packages with security patches and releases.

Meaning Ubuntu users will always have a fresh new .NET LTS in each Ubuntu LTS series.” announced in Ubuntu blog.

To get it, simply open terminal by pressing Ctrl + Alt + T on keyboard, and run commands:

sudo apt install dotnet6

Simply replace dotnet6 with dotnet7 in command will install .NET 7 instead.

You may first run sudo apt update to refresh cache, in case the command above does not work!

This command will install all the SDK, runtime and ASP.NET packages! To install them separately, user may run either command below in a terminal window:

sudo apt install dotnet-sdk-6.0
sudo apt install dotnet-runtime-6.O
sudo apt install aspnetcore-runtime-6.0

After installation, verify .NET version via dotnet --version and use dotnet --help to print the basic how to use description.

Install .NET 6, 7, or 8 in other Linux

Microsoft has been maintaining its own Linux repositories for a few years. There user can get many software packages including .NET framework as easy as a few commands.

And, here’s how to add the repository and install .NET in Ubuntu 18.04, Ubuntu 20.04, Linux Mint 20, Debian 9 / 10 / 11/12, SUSE Linux 12/15, CentOS 8, Fedora 36/37/38, and RHEL 7/8/9.

Step 1: Add Microsoft Repository

First of all, you need to either open a terminal window or connect to your Linux server command console. Then select run the commands below for your system.

For Debian

Debian has updated its policy for adding third-party repositories. The official guide in Microsoft website is outdated and deprecated.

First, install the key by running command to download the key, dearmor it, and put it into ‘/usr/share/keyrings‘ directory:

curl | gpg --dearmor | sudo dd of=/usr/share/keyrings/microsoft.gpg

Type user password and hit Enter if it stuck at blinking cursor!

Then, add the repository for Debian 12 via command:

printf 'deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] bookworm main\n' | sudo tee /etc/apt/sources.list.d/microsoft.list >/dev/null

For Debian 11, use this command instead to add repository:

printf 'deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] bullseye main\n' | sudo tee /etc/apt/sources.list.d/microsoft.list >/dev/null

And for Debian 9 / 10, replace the number to 9 or 10 and codename to stretch or buster in the command.

For Ubuntu/Linux Mint

Linux Mint 21 and other Ubuntu 22.04 based systems can directly install .NET 6/7 packages via the apt command.

For old systems, run the commands below one by one to add the software repository.

First, install the key by running command to download the key file and install to the right place:

curl | gpg --dearmor | sudo dd of=/usr/share/keyrings/microsoft.gpg

Ubuntu does not has curl out-of-box, install it via 'sudo apt install curl' command.
And, type user password and hit Enter if it stuck at blinking cursor!

Next, add the repository for Ubuntu 20.04 via command:

printf 'deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] focal main\n' | sudo tee /etc/apt/sources.list.d/microsoft.list >/dev/null

Or use this command instead for Ubuntu 18.04:

printf 'deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] bionic main\n' | sudo tee /etc/apt/sources.list.d/microsoft.list >/dev/null

If you want to install .NET 8 in Ubuntu 22.04, add the repository via command:

printf 'deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] jammy main\n' | sudo tee /etc/apt/sources.list.d/microsoft.list >/dev/null

Add Microsoft Repository in Ubuntu 20.04

For RHEL/Fedora/SUSE/CentOS

A single command can do the job adding the Microsoft repository in this step. Simply choose the command for your Linux:

For RHEL, use the command below with different version number depends on your system:

sudo rpm -Uvh

And, Fedora user can add the repository via command (also change number 39 accordingly):

sudo rpm -Uvh

For SUSE Linux, use command (change number 15 according system version):

sudo rpm -Uvh

And CentOS 8 can add the repository via the single command below:

sudo rpm -Uvh

Step 2: Install .NET SDK/Runtime & ASP.NET

After set up the software repositories, user can now install the framework via command below. Replace 6.0 in commands below with 7.0 or 8.0, depends on which version you want to install.

For Debian/Ubuntu and their derivatives, e.g., Linux Mint, Pop! OS, Zorin OS, use command below to refresh cache & install .NET framework:

sudo apt install dotnet-sdk-6.0 dotnet-runtime-6.0 aspnetcore-runtime-6.0
sudo apt update command is required to update package cache.

Fedora/RHEL/CentOS users can use the command below instead (replace dnf if not work with yum):

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

And, SUSE Linux users can run the command below in terminal to install the framework:

sudo zypper install dotnet-sdk-6.0 dotnet-runtime-6.0 aspnetcore-runtime-6.0

(Optional) Remove .NET in Linux

In case you want to remove the software packages, use command below in Debian, Ubuntu, Linux Mint (also replace 6.0 with 7.0 or 8.0 accordingly):

sudo apt remove dotnet-sdk-6.0 dotnet-runtime-6.0 aspnetcore-runtime-6.0

For Fedora/CentOS/RHEL, replace apt with dnf or yum in command. Or, use zypper instead for SUSE Linux.

And, to remove the Microsoft repository, simply remove the source file:

  • For Ubuntu/Debian:
    sudo rm /etc/apt/sources.list.d/microsoft.list
  • For Fedora/RHEL/SUSE:
    sudo rm /etc/yum.repos.d/microsoft-prod.repo


Installing .NET framework is quite easy now in Ubuntu 22.04 LTS. But, it’s not hard for other Linux, since Microsoft maintains Linux repositories for the latest software packages.

Hi, I'm Merilyn Ne, a computer geek working on Ubuntu Linux for many years and would like to write useful tips for beginners. Forgive me for language mistakes. I'm not a native speaker of English.