Solution 1:

According to this how-to, before uninstalling MiKTeX you need to first reset your install to factory defaults using the MiKTeX console:

  1. Launch the MiKTeX Console desktop application (search for "MiKTeX Console" in the application launcher).
  2. Click "Cleanup" to navigate to the cleanup page.
  3. Click "Reset the TeX installation" to factory defaults.

This resets the TeX installation to the initial state, deleting all the files and directories created by the MiKTeX installer. You can now uninstall via the command line:

sudo apt-get remove miktex
sudo apt autoremove