Skip to content
Ubuntu Linux

How to Install .NET 7 on Ubuntu Linux

Richard
Written by
Richard
Updated 4 min read
How to Enable or Disable Microsoft Defender Cloud Protection
How to Enable or Disable Microsoft Defender Cloud Protection

.NET 7 is a Microsoft software platform for building and running apps on Ubuntu Linux 22.04 or 20.04. Ubuntu does not include it in its standard software list, so you first set up the official Microsoft package repository. After that, the install works like any other package.

The whole setup takes a few terminal commands. You add Microsoft’s signing key, add a repository file that matches your Ubuntu release, and then run the install. You need an account with sudo rights and an internet connection. To open a terminal on a standard Ubuntu desktop, press Ctrl+Alt+T.

Support note: .NET 7 was a short-term release, and Microsoft ended support for it in May 2024. It still installs and runs. For new production work, check whether a newer supported .NET version fits your project better.

⚡ Quick Answer

To install.NET 7 on Ubuntu, first add Microsoft’s package signing key and repository file, then run sudo apt install dotnet-sdk-7.0 in the terminal (press Ctrl+Alt+T to open it). Use the repository line that matches your release: 22.04 or 20.04. You need sudo rights and an internet connection. Microsoft ended support for.NET 7 in May 2024.

Advertisement

How to install .NET 7 on Ubuntu Linux

As described above, Microsoft announced the release of .NET 7 with enhanced Linux and native ARM64 support. That means the same platform runs on ARM64 machines as well as regular 64-bit PCs.

Below is how to install it on Ubuntu Linux. The sections run in order: first an optional .NET 6 install from Ubuntu’s own sources, then the .NET 7 install from Microsoft’s repository.

Advertisement

Install .NET 6

💡TipYou can install .NET 6 on Ubuntu with the built-in package manager. Two commands in the terminal add the development tools and runtime files, and you don’t need any extra download sources. Use this section if .NET 6 is enough for your project. If you only want .NET 7, skip ahead to the Microsoft repository section.

To install .NET 6, run the commands below in your terminal. Enter your password when sudo asks for it. Nothing shows on screen while you type it, which is normal.

🐧Bash / Shell
sudo apt update
sudo apt install dotnet6

The commands above install all the SDK, Runtime, and ASP.NET packages. The SDK is what you need to build and test apps, and it includes the tools to run them as well. The runtime runs finished apps, and the ASP.NET package runs web apps.

💡TipIf you don’t need everything, you can install each feature on its own. A server that only runs finished apps, for example, does not need the SDK. Installing fewer packages also saves disk space.
🐧Bash / Shell
sudo apt install dotnet-sdk-6.0
sudo apt install dotnet-runtime-6.O
sudo apt install aspnetcore-runtime-6.0

Install .NET 7

Installing .NET 7 on Ubuntu means setting up Microsoft’s official software repository first. The package is not in the default Ubuntu app lists. You download Microsoft’s security key and then tell your system to trust the official Microsoft download source. Only after that do you run the install command.

First, run the commands below to add the Microsoft repository’s GPG key. The key lets Ubuntu check that the packages really come from Microsoft and were not changed on the way. When the commands finish without errors, the key is in place.

🐧Bash / Shell
sudo apt install curl
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo dd of=/usr/share/keyrings/microsoft.gpg

Once the repository GPG key is installed, run the commands below to create a repository file. There is one set of commands for each version of Ubuntu. Run only the set that matches your system. To check which release you have, open Settings About and read the OS name.

For version 22.04:

⬛Command Prompt
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/ubuntu/22.04/prod jammy main' | sudo tee /etc/apt/sources.list.d/microsoft.list >/dev/null

For version 20.04:

⬛Command Prompt
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/ubuntu/20.04/prod focal main' | sudo tee /etc/apt/sources.list.d/microsoft.list >/dev/null

For version 18.04:

⬛Command Prompt
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/ubuntu/18.04/prod bionic main' | sudo tee /etc/apt/sources.list.d/microsoft.list >/dev/null

After adding the repository’s key and file, run the commands below to install .NET 7. This downloads the packages from Microsoft’s repository, so it can take a minute or two depending on your connection. If the terminal says it cannot find the package, check that you used the repository file for your own Ubuntu version and that the key step finished without errors.

🐧Bash / Shell
sudo apt update
sudo apt install dotnet-sdk-7.0
sudo apt install dotnet-runtime-7.0 
sudo apt install aspnetcore-runtime-7.0

To confirm the install worked and see details about .NET, run the commands below. You don’t need to restart the computer.

💻Code
dotnet --info

That should output lines similar to the ones below. Look for a 7.0 version number in the SDK and runtime details. If you also installed .NET 6, you may see both versions listed, and that is fine.

💻Code
.NET SDK:

 Version:   7.0.100
 Commit:    e12b7af219
Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.10
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/7.0.100/
Host:
  Version:      7.0.0
  Architecture: x64
  Commit:       d099f075e4
.NET SDKs installed:
  7.0.100 [/usr/share/dotnet/sdk]
.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
  None
Environment variables:
  Not set
global.json file:
  Not found
Learn more:
  https://aka.ms/dotnet/info
Download .NET:
  https://aka.ms/dotnet/download

That should do it! .NET 7 is now installed, and you can start building and running apps.

Reference:

Conclusion:

  • This guide shows the steps to install Microsoft .NET 7 on Ubuntu Linux using the official Microsoft .NET repository.
  • Follow the procedure and you can set up .NET 7 on your Ubuntu system, even though .NET 7 packages are not in the default repositories.
  • The guide covers both .NET 6 and .NET 7, so you can pick the version your projects need and use the new features and performance improvements that .NET 7 brings.
  • For further details and discussion, use the comment section in the reference link.

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?

Richard

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.

Advertisement

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *