如何在Ubuntu 20.04系统中卸载ASP.NET Core 3.1(为安装.NET Core 5.0做准备)
Hey there! Looking at your command outputs, I notice your .NET Core 3.1 is installed via Snap (the paths like /snap/dotnet-sdk/141/ give this away), not through Ubuntu's apt package manager. That's exactly why your apt remove commands failed—those specific package names don't exist in the apt repository.
Here's the correct way to uninstall it using Snap tools:
First, confirm the exact snap package name related to your .NET installation. Run this command to list all dotnet-related snaps:
snap list | grep dotnetFrom your existing path, it's almost certainly
dotnet-sdk(revision 141), but this command will give you definitive info.Next, remove the SDK snap package. Since the ASP.NET Core and .NET Core runtimes are bundled within the SDK snap for this installation, removing the SDK will take care of both runtimes too. Execute:
sudo snap remove dotnet-sdkIf you had a separate runtime snap installed (unlikely in your case), you could remove that with
sudo snap remove dotnet-runtime, but the SDK removal should handle everything from your listed runtimes.Finally, verify the uninstallation worked by re-running the list commands:
dotnet --list-sdks dotnet --list-runtimesYou should no longer see any entries for .NET Core 3.1.
A quick reminder: Snap packages are self-contained, so removing the snap automatically cleans up all associated files in the /snap directory—no extra --purge flags are needed like with apt.
内容的提问来源于stack exchange,提问作者hanu




