sudo apt-get install dotnet code example

Example: install dotnet core ubuntu

# add the Microsoft package signing key to your list of trusted keys 
# and add the package repository.
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

# if you want to develop applications then you need to install the SDK
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-3.1
  
# if all you want to do is to run the applications made with .NET Core
# then you don't need to install the whole SDK, just install the runtime
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y aspnetcore-runtime-3.1