This short tutorial how to install Microsoft .NET on Ubuntu 20.04. 18.04 LTS.

Developers wishing to develop .NET applications on Ubuntu, the first thing to do is to install the .NET framework. Initially, the .NET Framework only supported Windows systems. Other systems and operating systems were excluded.

With the latest .NET 5 release, it was developed as a cross-platform and open-source framework. It now supports Linux and MacOS systems out of the box. It is also modular and lightweight

The best way to use .NET on Ubuntu is to install the Software Development Kit (SDK), which also includes the .NET runtime by default. This will allow you to develop and run .NET applications.

 

To get started with installing the .NET SDK on Ubuntu, follow the steps below:

Install required package

Before installing the .NET SDK, you will want to install some basic packages. This package allows you to securely install .NET SDK via HTTPS

To do this, be sure to install Apt-transport-https Package using the below command.

sudo apt update
sudo apt install apt-transport-https

Add .NET Repository

Now that the package has been installed above, run the below command to add Microsoft’s package repository to your system.

wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb

Install .NET 5 SDK

After that, you should only be able to install .NET by running the commands below.

sudo apt update
sudo apt install dotnet-sdk-5.0

After installing, you should get a successful message like the one below:

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 Telemetry
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry Configuring…
A command is running to populate your local package cache to improve restore speed and enable offline access. This command takes up to one minute to complete and only runs once.
Processing triggers for man-db (2.9.1-1) …

After installing, you can verify that .NET is installed by running the commands below.

dotnet --list-sdks

The above command will display the installed version of .NET.

Output:
5.0.202 [/usr/share/dotnet/sdk]

Also verify that the .NET runtime is working.

dotnet --list-runtimes

The same lines should be displayed as shown below:

Output:
Microsoft.AspNetCore.App 5.0.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Install .NET via snap

Alternatively, one can install .NET via snap package management. Some people would prefer to install .NET via Snap as it can be the fastest and easiest.

Snap There are containerized software packages that are easy to create and install.

Snap applications are packed with all their dependencies so that they can run on all popular Linux distributions from a single build that allows them to automatically update and roll back gracefully.

To install .NET via snap, run the following command:

sudo apt install snap 
sudo snap install dotnet-sdk --classic

After installing, you can start creating great applications.

Conclusion:

This post showed you how to install .NET SDK on Ubuntu 20.04.

You may also like the post below:

How to install Kali Linux 2021.1