How to Install DotNet Core SDK on Ubuntu 18.04 LTS

In this article, We are going to perform How to Install DotNet Core SDK on Ubuntu 18.04 LTS or any other cloud platform like Amazon EC2, Azure VM , Google compute cloud, etc., with preinstalled Ubuntu.


.NET Core is a free and open-source, software framework for Windows, Linux, and macOS operating systems. It is an open source, cross platform successor to .NET Framework.

Download and Install Microsoft keys for Ubuntu

First download and Install Microsoft keys for ubuntu 18.04 LTS using below command

$ sudo wget -O packages-microsoft-prod.deb


Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3132 (3.1K) [application/octet-stream]
Saving to: ‘packages-microsoft-prod.deb’

packages-microsoft-prod.deb 100%[================================================================================>] 3.06K --.-KB/s in 0s

(524 MB/s) - ‘packages-microsoft-prod.deb’ saved [3132/3132]

Install Microsoft keys and feeds deb package.

$ sudo dpkg -i packages-microsoft-prod.deb

Install dependencies packages first

$ sudo add-apt-repository universe

$ sudo apt-get update

$ sudo apt-get install apt-transport-https

$ sudo apt-get update

Install DotNet Core SDK on Ubuntu

Install dotnet core sdk 2.1 on ubuntu. To install specific version follow Microsoft official documentation.

$ sudo apt-get install dotnet-sdk-2.1

If you want to install dotnet core sdk  3.1 on ubuntu

$ sudo apt-get install dotnet-sdk-3.1

To verify if DotNet core in installed

$ dotnet


Usage: dotnet [options]
Usage: dotnet [path-to-application]

-h|--help Display help.
--info Display .NET Core information.
--list-sdks Display the installed SDKs.
--list-runtimes Display the installed runtimes.

The path to an application .dll file to execute.

To check dotnet core version

$ dotnet --version


dotnet --version

Creating .NET core Project

Lets create directory named testproject

$ sudo mkdir testproject

Navigate to testproject directory

$ cd testproject/

Lets create new dot net project named fosstechnix

$ sudo dotnet new console -o fosstechnix


The template "Console Application" was created successfully.

Processing post-creation actions...

Running 'dotnet restore' on fosstechnix/fosstechnix.csproj...

  Restore completed in 161.24 ms for /home/user/testproject/fosstechnix/fosstechnix.csproj.

Restore succeeded.

Now, navigate to the project directory with the following command:

$ cd fosstechnix/

Check the project files

$ ls



fosstechnix.csproj  obj  Program.cs

To check main program file

$ cat Program.cs


cat Program.cs

using System;

namespace fosstechnix


    class Program


        static void Main(string[] args)


            Console.WriteLine("Hello World!");




Running .NET core project

Use below command to run dotnet project

$ sudo dotnet run


sudo dotnet run

Hello World!


We have covered How to Install DotNet Core SDK on Ubuntu 18.04 LTS

Related Articles

How to Download and Install Java SE JDK 8 on Windows 10

FOSS TechNix

FOSS TechNix (Free,Open Source Software's and Technology Nix*) founded in 2019 is a community platform where you can find How-to Guides, articles for DevOps Tools,Linux and Databases.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link
Powered by Social Snap