How to Install .NET Core (Dotnet) SDK on Ubuntu Linux
The .NET Core (dotnet) SDK is a set of Microsoft tools for building and running apps on Ubuntu Linux. It includes the compiler, the libraries and the runtime you need to write programs in languages like C#. This guide covers the SDK on Ubuntu from the terminal.
Ubuntu can run major releases such as .NET 6 and .NET 8. Setup takes a few terminal commands, and you need a user with sudo rights. One caution: .NET 6 has reached end of support. The original steps below use the 6.0 package, but for a new install pick a currently supported release, such as .NET 8 (LTS), by changing the version number in the package name.
To install the.NET SDK on Ubuntu, add Microsoft’s package repository, then run sudo apt update followed by sudo apt install dotnet-sdk-8.0 in a terminal. Use 8.0 (LTS) rather than 6.0, which has reached end of support. Run dotnet –version to confirm the install worked.
How to install dotnet (.NET) SDK on Ubuntu Linux
The apt method works in three parts. You add Microsoft’s software repository to your system, register the Microsoft package signing key so apt trusts that feed, and then use apt to download and install the SDK. The sections below follow that order.
Below is how to install it on Ubuntu Linux. Open a terminal first. Press Ctrl+Alt+T on most Ubuntu desktops, or connect to your server over SSH.
Before you install the .NET Core SDK, install a few helper packages. The first one lets apt download packages over HTTPS, so the SDK comes from a secure connection.
- Run the command in the block below to install the apt-transport-https package. The original text wrote this name with “HTTP”, but the real package name ends in “https”.
- Wait for the command to finish and return you to the prompt. If the package is already installed, apt says so and changes nothing. On recent Ubuntu releases HTTPS support is built into apt, so this step is harmless but often not needed.
sudo apt update sudo apt install apt-transport-https
Add .NET Repository
Adding the .NET repository tells your package manager where to find official Microsoft packages. You use wget to download Microsoft’s configuration package, then install it with dpkg so your system trusts the Microsoft feed.
- Run the wget command from the first block below. It downloads the Microsoft package file into your current folder.
- Run the dpkg command to install that file. You should see dpkg unpack and set up the package without errors.
- Optionally, delete the downloaded file afterward to keep your folder tidy. The repository stays in place.
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
These commands create the repository file microsoft-prod.list in the /etc/apt/sources.list.d/ folder. That file holds the feed settings apt uses to find Microsoft packages. You can open it with a text viewer to confirm it exists.
If you run a different version of Ubuntu Linux, replace the highlighted version number in the commands above with yours. Check your version with the lsb_release tool or by opening Settings About on a desktop install. If Microsoft does not publish a feed for your release, the download fails with a “404 Not Found” error.
Install .NET Core SDK on Ubuntu Linux
Now refresh the local package list and install the SDK. The order matters, because apt only learns about the new Microsoft packages after an update.
- Run sudo apt update. You should see the Microsoft repository in the list of sources apt contacts.
- Run sudo apt install dotnet-sdk-6.0 to install the SDK. For a supported release, use the same command with a newer version number, for example 8.0, in the package name.
- Type Y and press Enter if apt asks you to confirm the download.
sudo apt update sudo apt install dotnet-sdk-8.0
When the install finishes, apt returns to the prompt with no errors. You should see output similar to the one below. If you see “Unable to locate package”, the repository was not added correctly, or your Ubuntu version is not supported by that feed. Go back to the repository step and check the version number.
Welcome to .NET! --------------------- Learn more about .NET: https://aka.ms/dotnet-docs Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
Once the .NET SDK is installed, check that it works by running the commands below. You do not need to restart the machine or log out.
dotnet --list-sdks
The command above prints the version of .NET installed. If the terminal says the command is not found, close it, open a new one and try again.
Output: 6.0.300 [/usr/share/dotnet/sdk]
Also verify that the .NET runtime is working. The runtime is what actually runs your compiled apps, and it comes with the SDK.
dotnet --list-runtimes
That should display lines similar to the ones shown below. The version numbers will match the release you installed.
Output: Microsoft.AspNetCore.App 6.0.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
The commands below install the runtime on its own, without the full SDK. Strictly speaking this is the .NET runtime, not the older Windows-only .NET Framework. Use this on a server that only needs to run apps, not build them.
sudo apt install dotnet-runtime-6.0
How to install .NET Core SDK on Ubuntu via Snap
The snap bundles the software with its required dependencies. You use the snap command-line tool, so you do not need to add a repository or a signing key. Snap is preinstalled on Ubuntu Desktop. On some minimal server images you may need to install snapd first.
Snaps are containerized software packages that are simple to create and install.
A snap carries all its dependencies, so one build runs on all the popular Linux distributions. Snaps update automatically in the background, and you can roll back to an earlier revision if an update causes trouble.
To install .NET via snap, run the commands below. Use one method or the other, apt or snap, not both, so you do not end up with two copies of the SDK.
sudo apt install snapd sudo snap install dotnet-sdk --classic
After installing, run the version check from earlier to confirm it works. You can then begin building applications.
That should do it!
Conclusion:
- Microsoft .NET Core SDK is a versatile, cross-platform framework supporting Linux and Mac OS systems, including Ubuntu Linux.
- With the SDK and the .NET Runtime installed, developers can build and run .NET applications on Ubuntu Linux. Install the runtime alone if you only need to run apps.
- You can install the .NET Core SDK either through traditional package management (apt) or through the Snap package, so you can choose whichever fits your system.
- The Long Term Support (LTS) version 6.0 of the .NET Core SDK, supported for 3 years, features improved git integration with Visual Studio 2022. It is now past its end of support, so for new projects choose a current release such as .NET 8.
Have a question about this guide?
Answered by AI from this guide. Good questions may be added to this page — please don't include personal details.
Did this guide fix your problem?
About the Author
Richard
Tech Writer, IT Professional
Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.
No comments yet — be the first to share your thoughts!