Install .NET on Linux by using an install script or by extracting binaries

This article demonstrates how to install the .NET SDK or the .NET Runtime on Linux by using the install script or by extracting the binaries. For a list of distributions that support the built-in package manager, see Install .NET on Linux.

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.

.NET releases

There are two types of supported releases, Long Term Support (LTS) releases or Standard Term Support (STS). The quality of all releases is the same. The only difference is the length of support. LTS releases get free support and patches for 3 years. STS releases get free support and patches for 18 months. For more information, see .NET Support Policy.

The following table lists the support status of each version of .NET (and .NET Core):

✔️ Supported ❌ Unsupported
7 (STS) 5
6 (LTS) 3.1
3.0
2.2
2.1
2.0
1.1
1.0

Dependencies

It's possible that when you install .NET, specific dependencies may not be installed, such as when manually installing. The following list details Linux distributions that are supported by Microsoft and have dependencies you may need to install. Check the distribution page for more information:

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

RPM dependencies

If your distribution wasn't previously listed, and is RPM-based, you may need the following dependencies:

  • krb5-libs
  • libicu
  • openssl-libs

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

DEB dependencies

If your distribution wasn't previously listed, and is debian-based, you may need the following dependencies:

  • libc6
  • libgcc1
  • libgssapi-krb5-2
  • libicu67
  • libssl1.1
  • libstdc++6
  • zlib1g

Common dependencies

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 usually install a recent version of libgdiplus by adding the Mono repository to your system.

Scripted install

The dotnet-install scripts are used for automation and non-admin installs of the SDK and Runtime. You can download the script from https://dot.net/v1/dotnet-install.sh. When .NET is installed in this way, you'll need to install dependencies required by your Linux distribution. Use the links in the Install .NET on Linux article for your specific Linux distribution.

Important

Bash is required to run the script.

You can download the script with wget:

wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh

Before running this script, you'll need to grant permission for this script to run as an executable:

sudo chmod +x ./dotnet-install.sh

The script defaults to installing the latest long term support (LTS) SDK version, which is .NET 6. To install the latest release, which may not be an (LTS) version, use the --version latest parameter.

./dotnet-install.sh --version latest

To install .NET Runtime instead of the SDK, use the --runtime parameter.

./dotnet-install.sh --version latest --runtime aspnetcore

You can install a specific major version with the --channel parameter to indicate the specific version. The following command installs .NET 7.0 SDK.

./dotnet-install.sh --channel 7.0

For more information, see dotnet-install scripts reference.

To enable .NET on the command line, see Set environment variables system-wide.

Manual install

As an alternative to the package managers, you can download and manually install the SDK and runtime. Manual installation is commonly used as part of continuous integration testing or on an unsupported Linux distribution. For a developer or user, it's better to use a package manager.

Download a binary release for either the SDK or the runtime from one of the following sites. The .NET SDK includes the corresponding runtime:

Extract the downloaded file and use the export command to set DOTNET_ROOT to the extracted folder's location and then ensure .NET is in PATH. Exporting DOTNET_ROOT makes the .NET CLI commands available in the terminal. For more information about .NET environment variables, see .NET SDK and CLI environment variables.

Alternatively, after downloading the .NET binary, the following commands may be run from the directory where the file is saved to extract the runtime. Running the following commands makes the .NET CLI commands available at the terminal and sets the required environment variables. Remember to change the DOTNET_FILE value to the name of the downloaded binary:

DOTNET_FILE=dotnet-sdk-7.0.100-linux-x64.tar.gz
export DOTNET_ROOT=$(pwd)/.dotnet

mkdir -p "$DOTNET_ROOT" && tar zxf "$DOTNET_FILE" -C "$DOTNET_ROOT"

export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools

The preceding install script approach allows installing different versions into separate locations so you can choose explicitly which one to use by which app.

Set environment variables system-wide

If you used the previous install script, the variables set only apply to your current terminal session. Add them to your shell profile. There are a number of different shells available for Linux and each has a different profile. For example:

  • Bash Shell: ~/.bash_profile, ~/.bashrc
  • Korn Shell: ~/.kshrc or .profile
  • Z Shell: ~/.zshrc or .zprofile

Set the following two environment variables in your shell profile:

  • DOTNET_ROOT

    This variable is set to the folder .NET was installed to, such as $HOME/.dotnet:

    export DOTNET_ROOT=$HOME/.dotnet
    
  • PATH

    This variable should include both the DOTNET_ROOT folder and the user's .dotnet/tools folder:

    export PATH=$PATH:$HOME/.dotnet:$HOME/.dotnet/tools
    

Next steps