command to check the dotnet sdk version you are currently using, it will list all the installed dotnet SDKs in your computer.
You can also use
to list sdks and runtimes separately.
Once you decided which version to be removed, execute command
sudo rm -rf /usr/local/share/dotnet/sdk/[version number here]
#remove .NET Core runtime
sudo rm -rf /usr/local/share/dotnet/shared/Microsoft.NETCore.App/[version number here]
#remove ASP.NET Core runtime
sudo rm -rf /usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/[version number here]
#I actually don't know what is in this directory
sudo rm -rf /usr/local/share/dotnet/host/fxr/[version number here]