Install the .NET SDK or the .NET Runtime on RHEL and CentOS Stream

Important

.NET 8 was released on November 14, 2023. It may take time for the packages to appear in the package manager feeds.

.NET is supported on Red Hat Enterprise Linux (RHEL). This article describes how to install .NET on RHEL and CentOS Stream.

Install the SDK (which includes the runtime) if you want to develop .NET apps. Or, if you only need to run apps, install the Runtime. If you're installing the Runtime, we suggest you install the ASP.NET Core Runtime as it includes both .NET and ASP.NET Core runtimes.

Use the dotnet --list-sdks and dotnet --list-runtimes commands to see which versions are installed. For more information, see How to check that .NET is already installed.

Register your Red Hat subscription

To install .NET from Red Hat on RHEL, you first need to register using the Red Hat Subscription Manager. If this hasn't been done on your system, or if you're unsure, see the Red Hat Product Documentation for .NET.

Important

This doesn't apply to CentOS Stream.

Supported distributions

The following table is a list of currently supported .NET releases on both RHEL and CentOS Stream. These versions remain supported until either the version of .NET reaches end-of-support or the Linux distribution is no longer supported.

Distribution .NET
RHEL 9 (9.1) 8, 7, 6
RHEL 8 (8.7) 8, 7, 6
RHEL 7 6
CentOS Stream 9 8, 7, 6
CentOS Stream 8 8, 7, 6

The following versions of .NET are ❌ no longer supported:

  • .NET 5
  • .NET Core 3.1
  • .NET Core 3.0
  • .NET Core 2.2
  • .NET Core 2.1
  • .NET Core 2.0

Install preview versions

Preview and release candidate versions of .NET aren't available in package repositories. You can install previews and release candidates of .NET in one of the following ways:

Remove preview versions

When using a package manager to manage your installation of .NET, you may run into a conflict if you've previously installed a preview release. The package manager may interpret the non-preview release as an earlier version of .NET. To install the non-preview release, first uninstall the preview versions. For more information about uninstalling .NET, see How to remove the .NET Runtime and SDK.

RHEL 9

.NET is included in the AppStream repositories for RHEL 9.

Important

.NET 8 was released on November 14, 2023. It may take time for the packages to appear in the package manager feeds.

Install the SDK

The .NET SDK allows you to develop apps with .NET. If you install the .NET SDK, you don't need to install the corresponding runtime. To install the .NET SDK, run the following command:

sudo dnf install dotnet-sdk-8.0

Install the runtime

The ASP.NET Core Runtime allows you to run apps that were made with .NET that didn't provide the runtime. The following command installs the ASP.NET Core Runtime, which is the most compatible runtime for .NET. In your terminal, run the following command:

sudo dnf install aspnetcore-runtime-8.0

As an alternative to the ASP.NET Core Runtime, you can install the .NET Runtime, which doesn't include ASP.NET Core support: replace aspnetcore-runtime-8.0 in the previous command with dotnet-runtime-8.0:

sudo dnf install dotnet-runtime-8.0

RHEL 8

.NET is included in the AppStream repositories for RHEL 8.

Important

.NET 8 was released on November 14, 2023. It may take time for the packages to appear in the package manager feeds.

Install the SDK

The .NET SDK allows you to develop apps with .NET. If you install the .NET SDK, you don't need to install the corresponding runtime. To install the .NET SDK, run the following command:

sudo dnf install dotnet-sdk-8.0

Install the runtime

The ASP.NET Core Runtime allows you to run apps that were made with .NET that didn't provide the runtime. The following command installs the ASP.NET Core Runtime, which is the most compatible runtime for .NET. In your terminal, run the following command:

sudo dnf install aspnetcore-runtime-8.0

As an alternative to the ASP.NET Core Runtime, you can install the .NET Runtime, which doesn't include ASP.NET Core support: replace aspnetcore-runtime-8.0 in the previous command with dotnet-runtime-8.0:

sudo dnf install dotnet-runtime-8.0

RHEL 7 ❌ .NET 8

.NET 8 isn't compatible with RHEL 7 and doesn't work.

RHEL 7 ❌ .NET 7

.NET 7 isn't officially supported on RHEL 7. To install .NET 7, see Install .NET on Linux by using an install script or by extracting binaries.

RHEL 7 ✔️ .NET 6

The following command installs the scl-utils package:

sudo yum install scl-utils

Install the SDK

The .NET SDK allows you to develop apps with .NET. If you install the .NET SDK, you don't need to install the corresponding runtime. To install .NET SDK, run the following commands:

subscription-manager repos --enable=rhel-7-server-dotnet-rpms
yum install rh-dotnet60 -y
scl enable rh-dotnet60 bash

Red Hat does not recommend permanently enabling rh-dotnet60 because it may affect other programs. If you want to enable rh-dotnet permanently, add the following line to your ~/.bashrc file.

source scl_source enable rh-dotnet60

Install the runtime

The .NET Runtime allows you to run apps that were made with .NET that didn't include the runtime. The commands below install the ASP.NET Core Runtime, which is the most compatible runtime for .NET Core. In your terminal, run the following commands.

subscription-manager repos --enable=rhel-7-server-dotnet-rpms
yum install rh-dotnet60-aspnetcore-runtime-6.0 -y
scl enable rh-dotnet60 bash

Red Hat does not recommend permanently enabling rh-dotnet60 because it may affect other programs. If you want to enable rh-dotnet60 permanently, add the following line to your ~/.bashrc file.

source scl_source enable rh-dotnet60

As an alternative to the ASP.NET Core Runtime, you can install the .NET Runtime that doesn't include ASP.NET Core support: replace rh-dotnet60-aspnetcore-runtime-6.0 in the preceding command with rh-dotnet60-dotnet-runtime-6.0.

CentOS Stream 9 ✔️

.NET is included in the AppStream repositories for CentOS Stream 9.

Install the SDK

The .NET SDK allows you to develop apps with .NET. If you install the .NET SDK, you don't need to install the corresponding runtime. To install the .NET SDK, run the following command:

sudo dnf install dotnet-sdk-8.0

Install the runtime

The ASP.NET Core Runtime allows you to run apps that were made with .NET that didn't provide the runtime. The following command installs the ASP.NET Core Runtime, which is the most compatible runtime for .NET. In your terminal, run the following command:

sudo dnf install aspnetcore-runtime-8.0

As an alternative to the ASP.NET Core Runtime, you can install the .NET Runtime, which doesn't include ASP.NET Core support: replace aspnetcore-runtime-8.0 in the previous command with dotnet-runtime-8.0:

sudo dnf install dotnet-runtime-8.0

CentOS Stream 8 ✔️

Use the Microsoft repository to install .NET:

sudo rpm -Uvh https://packages.microsoft.com/config/centos/8/packages-microsoft-prod.rpm
sudo yum install dotnet-sdk-8.0

Dependencies

When you install with a package manager, these libraries are installed for you. But, if you manually install .NET or you publish a self-contained app, you'll need to make sure these libraries are installed:

  • krb5-libs
  • libicu
  • openssl-libs
  • zlib

If the target runtime environment's OpenSSL version is 1.1 or newer, you'll need to install compat-openssl10.

Dependencies can be installed with the yum install command. The following snippet demonstrates installing the libicu library:

sudo yum install libicu

For more information about the dependencies, see Self-contained Linux apps.

If the .NET app uses the System.Drawing.Common assembly, libgdiplus will also need to be installed. Because System.Drawing.Common is no longer supported on Linux, this only works on .NET 6 and requires setting the System.Drawing.EnableUnixSupport runtime configuration switch.

You can install a recent version of libgdiplus by adding the Mono repository to your system.

How to install other versions

Consult the Red Hat documentation for .NET on the steps required to install other releases of .NET.

Troubleshoot the package manager

This section provides information on common errors you may get while using the package manager to install .NET or .NET Core.

For more information about solving these problems, see Troubleshoot fxr, libhostfxr.so, and FrameworkList.xml errors.

Next steps