I use macOS instead of linux, but:
#download the latest version of the Microsoft install package
wget https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
#install the package
sudo dpkg -i packages-microsoft-prod.deb
#delete the download
rm packages-microsoft-prod.deb
apt-get is an alternative package installer to dpkg.
sudo apt-get update; \
sudo apt-get install -y apt-transport-https && \
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-6.0
line 1 updates apt-get to the latest version
line 2 install https support for apt-get
line 3 run apt-get update again
line 4 fetch and install dotnet-sdk-6.0
to install the 3.1 sdk you would need to know the package name. if you look at the 3.1 install instructions, they use apt rather than apt-get
sudo apt install dotnet-sdk-3.1
if you don't have apt, just download the tar file and extract t the correct folder.
DOTNET_FILE=dotnet-sdk-6.0.100-linux-x64.tar.gz
export DOTNET_ROOT=$(pwd)/.dotnet
mkdir -p "$DOTNET_ROOT" && tar zxf "$DOTNET_FILE" -C "$DOTNET_ROOT"
export PATH=$PATH:$DOTNET_ROOT
use the correct tar file name.