I have installed dotnet on my Ubuntu 20.10 but for some reason I want to remove it but I don't know how to do it please help.

enter image description here

6 Answers 6


Try with major and minor version only:

sudo apt remove --purge dotnet-sdk-6.0
sudo apt remove --purge dotnet-runtime-6.0
  • This worked for me! sudo apt purge dotnet-sdk-6.0
    – kol
    Commented Feb 23, 2022 at 14:11
  • before and after remove you can list: dotnet --list-sdks dotnet --list-runtimes
    – dgolive
    Commented Dec 29, 2023 at 0:40

Run these commands:

sudo apt remove --purge dotnet-sdk-5.0.101
sudo apt remove --purge dotnet-runtime-5.0.101
  • 2
    not working for me sudo dotnet --list-sdks 6.0.101 [/snap/dotnet-sdk/152/sdk] sudo apt remove --purge dotnet-sdk-6.0.101 Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package dotnet-sdk-6.0.101 E: Couldn't find any package by glob 'dotnet-sdk-6.0.101'
    – madan
    Commented Jan 7, 2022 at 10:37
  • @madan Try with "major.minor", like sudo apt purge dotnet-sdk-6.0
    – kol
    Commented Feb 23, 2022 at 14:13
  • thanks kol, i am afraid i do not currently have this issue so can't try the solution
    – madan
    Commented Feb 24, 2022 at 11:33

For the situation where dotnet has been installed using snap, you can do the following:

  1. You need to list the names of the snap packages by going to the /snap directory. For example, on Ubuntu 21, my dotnet installations are shown in the following script.

    $ cd /snap
    $ ls
  2. Then you can use the following commands to remove the snaps.

    sudo snap remove dotnet-sdk
    sudo snap remove dotnet-runtime-60

This was based on the answer for snap packages here: How to list files installed by a snap package?


All you have to do is just put the major version number, for example 3.1 or 5.0. You don't have to put any other minor version number/reference number just major version number will do.

For example for lets say your donet-sdk version is 3.1.416 then just right

sudo apt remove --purge dotnet-sdk-3.1
sudo apt remove --purge dotnet-runtime-3.1
  • FYI askubuntu.com/a/1388621/1210606 is the correct answer because this comment from am year ago askubuntu.com/questions/1305271/… showed it was a snap. Commented Jan 28, 2022 at 21:19
  • 1
    What a mess this is - been stuck for hours trying to install .net 6 & 7 - On my 5th full uninstall and reinstall - The FULL uninstall does not get rid of .NET so attempting a clean install not possible. The microsoft instructions dont work - no surprise there, and I cant find any reliable instructions anywhere. None of the above commands remove everything. After using remove or purge, dotnet cmd is still showing. The latest error is Segmentation Fault - corrupted memory.
    – Greg
    Commented Feb 21, 2023 at 19:25

All you have to do is run this to remove all

sudo apt-get purge dotnet-sdk-*
sudo apt-get purge dotnet-runtime-*

or use version

sudo apt remove --purge dotnet-sdk-6.0
sudo apt remove --purge dotnet-runtime-6.0

You can also use Synaptic to manage all installed versions.

sudo apt install synaptic

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .