How to Install .NET Core (dotnet) on Ubuntu 22.04

How to Install .NET Core (dotnet) on Ubuntu 22.04

Microsoft .NET Core is a free and open-source software framework designed with keeping Linux and macOS in mind. It is a cross-platform successor to .NET Framework available for Linux, macOS, and Windows systems. .NET Core 6 is an LTR release that will support for the next 3 years. It also supports hot reload and better git integration with Visual Studio 2022.

The Ubuntu 22.04 users can only install .NET Core 6.0. It doesn’t support .NET Core 3.1 or 2.0 since the distro only supports openSSL 3.

The developers should install the .NET Core SDK on their system and the staging or production server needs the .NET Core runtime only. This tutorial walks through installing .NET core on Ubuntu 22.04 LTS Linux system. You can install .NET Core SDK or set up the runtime environment on your system.

Step 1 – Enable Microsoft PPA

First of all, enable the Microsoft Apt repository on our Ubuntu systems. The Microsoft team provides a Debian package to set up the PPA on the Ubuntu system.

Open a terminal on your Ubuntu system and configure Microsoft PPA by running the following commands:

sudo dpkg -i packages-microsoft-prod.deb 

Above commands will create a /etc/apt/sources.list.d/microsoft-prod.list file in your system with the required configuration.

Let’s begin the .NET core installation on the Ubuntu system.

Step 2 – Installing .NET Core SDK on Ubuntu

.NET Core SDK is the Software development kit used for developing applications. If you are going to create an application or make changes to an existing application, you will require a .net core SDK package on your system.

To install .NET Core SDK on Ubuntu 22.04 LTS system, execute the following commands:

sudo apt install apt-transport-https 
sudo apt update 
sudo apt install dotnet-sdk-6.0 

Press “y” for any input prompted by the installer.

That’s it. You have successfully installed .Net core SDK on your Ubuntu system.

Step 3 – Installing .NET Core Runtime on Ubuntu

.NET Core Runtime is required for the system, where you only need to run the application. For example, production or stating environments are required to run applications only.

To install .NET Core Runtime only on Ubuntu 22.04 LTS system, type:

sudo apt install apt-transport-https 
sudo apt update 
sudo apt install dotnet-runtime-6.0 

Press “y” for any input prompted by the installer.

That’s it. You have successfully installed the .NET core runtime on your Ubuntu system.

Step 4 – Check .NET Core Version

You can use dotnet command line utility to check installed version of .NET Core on your system. To check dotnet version, type:

dotnet --version


Installing Dotnet Core on Ubuntu 22.04
Checking .NET Core Version

Step 5 – (Optional) Create a Sample Application

Let’s create a sample application with dotnet core on your Ubuntu system. Create a new console application with the command:

dotnet new console -o HelloWorld

This will create a .Net core application on your system. This will create a directory named “helloworld” under the current directory. You can change to this directory and start working on your application.

cd  HelloWorld

Make your changes to the application and execute the below command to run this application.

dotnet run

You will see the following output as a result.

Install  .NET Core on Ubuntu 22.04
Running .NET Core HelloWorld Application

Remove or Uninstall .NET Core on Ubuntu

In case, the .NET Core is not more required on your system. You can uninstall it from the system with the following commands.

sudo apt remove --purge dotnet-sdk-6.0 dotnet-runtime-6.0 

Also remove unused packages installed as dependecies:

sudo apt auto-remove 


In this tutorial, you have learned to install .NET Core SDK and Runtime on a Ubuntu 22.04 LTS (Jammy Jellyfish) Linux system. Now, you may like to install Visual Studio Code or Sublime Text editor on your Ubuntu desktop systems.

The post How to Install .NET Core (dotnet) on Ubuntu 22.04 appeared first on TecAdmin.

.net core dotnet dotnet core TecAdmin Ubuntu Ubuntu 22.04