In this tutorial, we will show you how to install Dotnet Core on Ubuntu 20.04 LTS. For those of you who didn’t know, Dotnet Core is an open-source, cross-platform software development framework that allows developers to build a wide range of applications, from web and mobile apps to cloud services and Internet of Things (IoT) solutions. With its modular design and support for multiple programming languages, Dotnet Core has become a popular choice among developers worldwide.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you through the step-by-step installation of Dotnet Core Microsoft on an Ubuntu 20.04 (Focal Fossa). You can follow the same instructions for Ubuntu 18.04, 16.04, and any other Debian-based distribution like Linux Mint.
Prerequisites
- A server running one of the following operating systems: Ubuntu 20.04, 18.04, 16.04, and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Dotnet Core on Ubuntu 20.04 LTS Focal Fossa
Step 1. To prepare your system, start by updating the package lists and upgrading any existing packages:
sudo apt update sudo apt upgrade
This step ensures that your system is up-to-date and ready for the Dotnet Core installation.
Step 2. Installing Dotnet Core on Ubuntu 20.04.
.NET Core is not available in the official package repository of Ubuntu 20.04 LTS. But, you can easily add the official Microsoft package repository on Ubuntu 20.04 LTS and install:
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 the .NET Core SDK
sudo apt update sudo apt install apt-transport-https sudo apt update sudo apt install dotnet-sdk-3.1
- Install the ASP.NET Core runtime
sudo apt update sudo apt install apt-transport-https sudo apt update sudo apt install aspnetcore-runtime-3.1
- Install the .NET Core runtime
sudo apt update sudo apt install apt-transport-https sudo apt update sudo apt install dotnet-runtime-3.1
Once installed successfully, you can use dotnet command-line utility to check the installed version of .NET Core on your system. To check dotnet version, type the following command:
$ dotnet --version 3.1.406
Step 4. Create a Sample Application Using .NET Program
Now we create a sample application with Dotnet core on your Ubuntu system:
dotnet new console -o HelloWorld
Then, 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
Congratulations! You have successfully installed Dotnet Core. Thanks for using this tutorial for installing the Dotnet Core Microsoft on your Ubuntu 20.04 LTS Focal Fossa system. For additional help or useful information, we recommend you check the official Dotnet Core website.