18

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

MarianD
  • 1,008
  • 2
  • 10
  • 15
Gaurav
  • 181
  • 1
  • 1
  • 3

5 Answers5

12

Try with major and minor version only:

sudo apt remove --purge dotnet-sdk-6.0
sudo apt remove --purge dotnet-runtime-6.0
BeastOfCaerbannog
  • 12,964
  • 10
  • 49
  • 77
user1983920
  • 131
  • 1
  • 2
11

Run these commands:

sudo apt remove --purge dotnet-sdk-5.0.101
sudo apt remove --purge dotnet-runtime-5.0.101
BeastOfCaerbannog
  • 12,964
  • 10
  • 49
  • 77
Edmund
  • 697
  • 3
  • 10
  • 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 07 '22 at 10:37
  • @madan Try with "major.minor", like `sudo apt purge dotnet-sdk-6.0` – kol Feb 23 '22 at 14:13
  • thanks kol, i am afraid i do not currently have this issue so can't try the solution – madan Feb 24 '22 at 11:33
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?

BeastOfCaerbannog
  • 12,964
  • 10
  • 49
  • 77
bkudrle
  • 71
  • 1
  • 3
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
  • FYI https://askubuntu.com/a/1388621/1210606 is the correct answer because this comment from am year ago https://askubuntu.com/questions/1305271/how-to-uninstall-dotnet-from-ubuntu-20-10-completely/1389528#comment2391729_1305274 showed it was a snap. – ChanganAuto Jan 28 '22 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 '23 at 19:25
0

You can also use Synaptic to manage all installed versions.

sudo apt install synaptic
Reza Taba
  • 101
  • 3