17

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

4 Answers 4

10

Run these commands:

sudo apt remove --purge dotnet-sdk-5.0.101
sudo apt remove --purge dotnet-runtime-5.0.101
3
  • 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
    Jan 7, 2022 at 10:37
  • @madan Try with "major.minor", like sudo apt purge dotnet-sdk-6.0
    – kol
    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
    Feb 24, 2022 at 11:33
9

Try with major and minor version only:

sudo apt remove --purge dotnet-sdk-6.0
sudo apt remove --purge dotnet-runtime-6.0
1
  • This worked for me! sudo apt purge dotnet-sdk-6.0
    – kol
    Feb 23, 2022 at 14:11
7

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
    ...
    dotnet-sdk
    dotnet-runtime-60
    ...
    
  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?

1

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
2
  • 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. 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
    Feb 21 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.