Reference

Offical guide: How to remove the .NET Core Runtime and SDK

Steps

  1. Use
    dotnet --info

    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
      dotnet --list-sdks

      and

      dotnet --list-runtimes

      to list sdks and runtimes separately.

  2. Once you decided which version to be removed, execute command
    #remove sdk
    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]

    to remove the sepecific SDK or runtime.