Install .NET on Linux by using an install script or by extracting binaries
Article
2024/11/11
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.
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
9 (STS)
7
8 (LTS)
6 (LTS)
5
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:
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 must install the dependencies required by your Linux distribution. Use the links in the Install .NET on Linux article for your specific Linux distribution.
Before running this script, make sure you grant permission for this script to run as an executable:
chmod +x ./dotnet-install.sh
The script defaults to installing the latest long term support (LTS) SDK version, which is .NET 8. To install the latest release, which might 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.
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.
Different versions of .NET can be extracted to the same folder, which coexist side-by-side.
Example
The following commands use Bash to set the environment variable DOTNET_ROOT to the current working directory followed by .dotnet. That directory is created if it doesn't exist. The DOTNET_FILE environment variable is the filename of the .NET binary release you want to install. This file is extracted to the DOTNET_ROOT directory. Both the DOTNET_ROOT directory and its tools subdirectory are added to the PATH environment variable.
Important
If you run these commands, remember to change the DOTNET_FILE value to the name of the .NET binary you downloaded.
After downloading an installer or binary release, verify it to make sure that the file hasn't been changed or corrupted. You can verify the checksum on your computer and then compare it to what was reported on the download website.
When you download the file from an official download page, the checksum for the file is displayed in a text box. Select the Copy button to copy the checksum value to your clipboard.
Use the sha512sum command to print the checksum of the file you've downloaded. For example, the following command reports the checksum of the dotnet-sdk-8.0.100-linux-x64.tar.gz file:
Compare the checksum with the value provided by the download site.
Important
Even though a Linux file is shown in these examples, this information equally applies to macOS.
Use a checksum file to validate
The .NET release notes contain a link to a checksum file you can use to validate your downloaded file. The following steps describe how to download the checksum file and validate a .NET install binary:
With both the checksum file and the .NET release file downloaded to the same directory, use the sha512sum -c {file} --ignore-missing command to validate the downloaded file.
When validation passes, you see the file printed with the OK status:
$ sha512sum -c 8.0.0-sha.txt --ignore-missing
dotnet-sdk-8.0.100-linux-x64.tar.gz: OK
If you see the file marked as FAILED, the file you downloaded isn't valid and shouldn't be used.
$ sha512sum -c 8.0.0-sha.txt --ignore-missing
dotnet-sdk-8.0.100-linux-x64.tar.gz: FAILED
sha512sum: WARNING: 1 computed checksum did NOT match
sha512sum: 8.0.0-sha.txt: no file was verified
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 many different shells available for Linux and each has a different profile. For example:
Bash Shell: ~/.bash_profile or ~/.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 DOTNET_ROOT/tools folder:
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET
feedback
.NET
is an open source project. Select a link to provide feedback:
Create a .NET project and learn to add packages and manage package dependencies in your project. Use the .NET Core CLI and NuGet registry to add libraries and tools to your C# applications through Visual Studio Code.