Installing DotNet Core in Ubuntu 20.04
Tags: dotnetcore, ubuntu, dotnet, focal
Published: 2020-04-24 15:55:20

**UPDATE: Microsoft added the official docs to [Install .NET Core on Ubuntu 20.04 package manager](https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-ubuntu-2004).**


**UPDATE 2: Added link to scripted installation alternative [Scripted Install](https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#scripted-install)**

The newest Ubuntu LTS release is available now. Sadly, at the time of this writing (April 24th), there is no official installation method for Ubuntu 20.04 listed on the .Net website.

# Manual Installation

For this tutorial we are going to manually install DotNet Core 3.1.201 SDK using the binaries provided in the official page.

## Download the binaries

Head to [.Net Core Downloads](https://dotnet.microsoft.com/download/dotnet-core/3.1) and look for the x64 Binaries in the Linux.

![Linux Binaries Download page](https://dev-to-uploads.s3.amazonaws.com/i/48a9f1i1ezf5by85fuxe.png)

Alternatively you can use [this link](https://dotnet.microsoft.com/download/dotnet-core/thank-you/sdk-3.1.201-linux-x64-binaries) to get the specific version used in this tutorial.

# Extract and link

After the download finishes, open a Terminal (you can use Super+Alt+T as a shortcut).

Navigate to the folder where it was downloaded and run the following command

```bash
mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-3.1.201-linux-x64.tar.gz -C $HOME/dotnet
```

This command will create a dotnet folder on the user's home directory and extract there the contents of the file.

**Note:** Please be aware that the file name `dotnet-sdk-3.1.201-linux-x64.tar.gz` matches the one you downloaded, otherwise you might need to modify the previous command accordingly to your download.

## Export variables 

Run the following commands to temporarily add the dotnet binaries in your terminal session.

```bash
export DOTNET_ROOT=$HOME/dotnet
```

and

```bash
export PATH=$PATH:$HOME/dotnet
```

**Note:** This will work only for the current session, at the end of the tutorial you will find instructions to add it permanently.

## Test the installation

Run `dotnet` in the Terminal, and the following should show appear:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/qlpohsg2r2i5k7mychg5.png)

**Congratulations!** You have installed dotnet core.

## Permanently add the dotnet command

To add the dotnet commands permanently, you need to add the dotnet folder to the path of your system. To achieve this need to modify the `~/.bashrc` file by running.

```bash
gedit ~/.bashrc
```

This will open an editor with the file contents. At the end of the file add the following two lines:

```bash
export PATH=$PATH:$HOME/dotnet
export DOTNET_ROOT=$HOME/dotnet
```
Save the file (Ctrl+S) and close all the open Terminal windows. Next time you open a new one `dotnet` will be available.

# Other installation methods

## Package Manager

This is the official way to install dotnet core for Ubuntu based systems. The instructions for the 20.04 version can be found in [Package Manager Install](https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#2004-)

## Scripted Install

It has been reported that some PopOS! users might have issues with the official and manual installation methods. In that case it might be solved by using the scripted install method whose instructions can be found in the following link [Scripted Install](https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#scripted-install). Thanks to [Emma](https://dev.to/maymeow) for the contribution.