Change Linux Mint to Ubuntu

TL;DR It is possible, but very difficult.

The method below is presented without any warranty. Use it on your own risk.

LinuxMint MATE 18.3 (Sylvia) -> Ubuntu Xenial Xerus 16.04 LTS

I have had installed LinuxMint MATE 18.3 (Sylvia). I asked myself a question - is it possible to convert it to normal Ubuntu Xenial Xerus 16.04 LTS without reinstallation?

I found great answer with script for listing packages from known repository. I adapted it to my situation:

cat > find_origin.sh << \EOF
LC_ALL=C dpkg-query --showformat='${Package}:${Status}\n' -W '*' | \
fgrep ':install ok installed' | cut -d: -f1 | \
(while read pkg; do inst_version=$(apt-cache policy $pkg \
| fgrep Installed: \
| awk '{ print $2 }'); origin=$(apt-cache policy "$pkg" \
| fgrep " *** ${inst_version}" -C1 \
| tail -n 1 \
| cut -c12-); echo $pkg $origin; done)
EOF

Then ran it to find Mint packages and remove them:

sh find_origin.sh | grep packages.linuxmint.com > mint-packages-all.txt


cat mint-packages-all.txt | grep -v "E:" | grep -v ^bash | grep -v ^base-files | grep -v ^mintsources | grep -v grub > mint-packages-remove.txt


sudo apt-get install aptitude
sudo aptitude purge $(cat mint-packages-remove.txt | awk '{print $1}')

sudo sed -i 's/^deb http:\/\/packages.linuxmint.com/#deb http:\/\/packages.linuxmint.com/g' /etc/apt/sources.list.d/official-package-repositories.list
sudo rm /etc/apt/preferences.d/official-package-repositories.pref

Then rebooted and launched Aptitude with sudo aptitude.
Set all packages from Obsolete and Locally Created Packages section to purge.

And checked locally installed package with:

sh find_origin.sh | grep /var

So I reinstalled two packages listed here - bash and base-files from xenial-updates repository from terminal:

sudo apt-get install bash=4.3-14ubuntu1.2 base-files=9.4ubuntu4.7

Then purged all packages that does not have ii state (such as rc) with:

sudo apt-get purge $(dpkg -l | grep -v ^ii | tail -n +6 | awk '{print $2}')
sudo apt-get install linux-image-generic linux-headers-generic
sudo apt-get purge linux-image-4.10.0-*-generic linux-headers-4.10.0-*-generic
sudo locale-gen en_US.UTF-8

Remove Mint files from home directory:

rm -rf ~/.linuxmint/

Check system integrity with debsums:

sudo apt-get install debsums
sudo debsums_init
sudo debsums -a -c # carefully check all files listed here with `dpkg -S filepath`

sudo apt-get install --reinstall cups-filters gnome-accessibility-themes im-config imagemagick sound-theme-freedesktop imagemagick-6.q16 libreoffice-draw libreoffice-math gnome-colors-common vino gnome-orca
sudo apt-get -o Dpkg::Options::="--force-confask" install --reinstall acpid libcompizconfig0 mate-menus systemd xdg-user-dirs-gtk vino # select Y

Then I checked system for files, that are not from Ubuntu repositories:

sudo find /bin /etc /lib /lib64 /opt /sbin /srv /usr /var -type f -exec dpkg -S {} \; 2> ~/Desktop/results.out

Removed the following objects:

sudo rm -rf /etc/linuxmint
sudo rm /usr/lib/python2.7/dist-packages/oneconf/distributor/LinuxMint.pyc

And finally installed Ubuntu MATE desktop:

sudo apt-get install ubuntu-mate-desktop^

Reboot and I have nearly normal Ubuntu Xenial 16.04 LTS :)

LinuxMint MATE 19 (Tara) -> Ubuntu Bionic Beaver 18.04 LTS

Warning: this method was not tested. Based on 18.3 -> 16.04 LTS above.

Let's do a listing of packages from known repository:

cat > find_origin.sh << \EOF
LC_ALL=C dpkg-query --showformat='${Package}:${Status}\n' -W '*' | \
fgrep ':install ok installed' | cut -d: -f1 | \
(while read pkg; do inst_version=$(apt-cache policy $pkg \
| fgrep Installed: \
| awk '{ print $2 }'); origin=$(apt-cache policy "$pkg" \
| fgrep " *** ${inst_version}" -C1 \
| tail -n 1 \
| cut -c12-); echo $pkg $origin; done)
EOF

Find Mint packages and remove them:

sh find_origin.sh | grep packages.linuxmint.com > mint-packages-all.txt


cat mint-packages-all.txt | grep -v "E:" | grep -v ^bash | grep -v ^base-files | grep -v ^mintsources | grep -v grub > mint-packages-remove.txt


sudo apt-get install aptitude
sudo aptitude purge $(cat mint-packages-remove.txt | awk '{print $1}')

sudo sed -i 's/^deb http:\/\/packages.linuxmint.com/#deb http:\/\/packages.linuxmint.com/g' /etc/apt/sources.list.d/official-package-repositories.list
sudo rm /etc/apt/preferences.d/official-package-repositories.pref

Launch Aptitude with sudo aptitude.
Set all packages from Obsolete and Locally Created Packages section to purge.

Check locally installed packages with:

sh find_origin.sh | grep /var

Reinstall two (maybe more!) packages listed here - bash and base-files from bionic-updates repository from terminal:

sudo apt-get install bash=4.4.18-2ubuntu1 base-files=10.1ubuntu2.1 desktop-file-utils=0.23-1ubuntu3.18.04

Then purge all packages that does not have ii state (such as rc) with:

sudo apt-get purge $(dpkg -l | grep -v ^ii | tail -n +6 | awk '{print $2}')
sudo apt-get install linux-image-generic linux-headers-generic
sudo locale-gen en_US.UTF-8

Remove Mint files from home directory:

rm -rf ~/.linuxmint/

Check system integrity with debsums:

sudo apt-get install debsums
sudo debsums_init
sudo debsums -a -c # carefully check all files listed here with `dpkg -S filepath`

sudo apt-get install --reinstall caja casper compton cups-filters engrampa gnome-icon-theme gnome-accessibility-themes im-config imagemagick libgs9 mate-desktop mate-icon-theme mate-screensaver mate-screensaver-common mate-system-monitor mate-utils openjdk-11-jre sound-theme-freedesktop imagemagick-6.q16 libreoffice-draw libreoffice-math gnome-colors-common vino gnome-orca
sudo apt-get -o Dpkg::Options::="--force-confask" install --reinstall acpid libcompizconfig0 mate-menus systemd xdg-user-dirs-gtk vino # select Y

Then check system for files, that are not from Ubuntu repositories:

sudo find /bin /etc /lib /lib64 /opt /sbin /srv /usr /var -type f -exec dpkg -S {} \; 2> ~/Desktop/results.out

Remove the following objects (may be other!):

sudo rm -rf /etc/linuxmint
sudo rm -rf /usr/lib/linuxmint
sudo rm /usr/lib/python2.7/dist-packages/oneconf/distributor/LinuxMint.pyc

And finally install Ubuntu MATE desktop:

sudo apt-get install lightdm-gtk-greeter ubuntu-mate-lightdm-theme ubuntu-mate-themes ubuntu-mate-wallpapers* ubuntu-mate-core ubuntu-mate-default-settings ubuntu-mate-artwork ubuntu-mate-icon-themes plymouth-theme-ubuntu-mate-logo plymouth-theme-ubuntu-mate-text grub2-themes-ubuntu-mate mate-tweak ubuntu-mate-guide caja-eiciel compiz-mate eom mate-accessibility-profiles mate-applet-appmenu mate-applet-brisk-menu mate-calc mate-dock-applet mate-hud mate-menu mate-netbook mate-optimus mate-user-guide mate-window-applets-common mate-window-buttons-applet mate-window-menu-applet mate-window-title-applet folder-color-caja deja-dup-caja gsettings-ubuntu-schemas indicator-messages indicator-power indicator-session indicator-sound brasero shotwell simple-scan smbclient ubuntu-standard vlc gdebi gdebi-core plank seahorse tilda sessioninstaller

Reset MATE desktop settings to the defaults:

dconf reset -f /org/mate
gsettings set org.mate.panel default-layout "'default'"

Install MATE Welcome and Software Boutique as Snaps:

snap install software-boutique --classic
snap install ubuntu-mate-welcome --classic

Reboot and have nearly normal Ubuntu Bionic 18.04 LTS :)

LinuxMint MATE 20 (Ulyana) -> Ubuntu Focal Fossa 20.04 LTS

Let's do a listing of packages from known repository:

cat > find_origin.sh << \EOF
LC_ALL=C dpkg-query --showformat='${Package}:${Status}\n' -W '*' | \
fgrep ':install ok installed' | cut -d: -f1 | \
(while read pkg; do inst_version=$(apt-cache policy $pkg \
| fgrep Installed: \
| awk '{ print $2 }'); origin=$(apt-cache policy "$pkg" \
| fgrep " *** ${inst_version}" -C1 \
| tail -n 1 \
| cut -c12-); echo $pkg $origin; done)
EOF

Find Mint packages and remove them:

sh find_origin.sh | grep packages.linuxmint.com > mint-packages-all.txt


cat mint-packages-all.txt | grep -v "E:" | grep -v ^bash | grep -v ^base-files | grep -v ^mintsources | grep -v grub > mint-packages-remove.txt


sudo apt-get install aptitude
sudo aptitude purge $(cat mint-packages-remove.txt | awk '{print $1}')

sudo sed -i 's/^deb http:\/\/packages.linuxmint.com/#deb http:\/\/packages.linuxmint.com/g' /etc/apt/sources.list.d/official-package-repositories.list
sudo rm /etc/apt/preferences.d/official-package-repositories.pref

Launch Aptitude with sudo aptitude.
Set all packages from Obsolete and Locally Created Packages section to purge.

Check locally installed packages with:

sh find_origin.sh | grep /var

Reinstall two (maybe more!) packages listed here - bash and base-files from focal-updates repository from terminal:

sudo apt-get install base-files=11ubuntu5 xapps-common=1.6.10-2

Then purge all packages that does not have ii state (such as rc) with:

sudo apt-get purge $(dpkg -l | grep -v ^ii | tail -n +6 | awk '{print $2}')
sudo apt-get install linux-image-generic linux-headers-generic
sudo locale-gen en_US.UTF-8

Remove Mint files from home directory:

rm -rf ~/.linuxmint/

Check system integrity with debsums:

sudo apt-get install debsums
sudo debsums_init
sudo debsums -a -c # carefully check all files listed here with `dpkg -S filepath`

sudo apt-get install --reinstall caja casper compton cups-filters engrampa gnome-icon-theme gnome-accessibility-themes im-config imagemagick libgs9 mate-desktop mate-icon-theme mate-screensaver mate-screensaver-common mate-system-monitor mate-utils openjdk-11-jre sound-theme-freedesktop imagemagick-6.q16 libreoffice-draw libreoffice-math gnome-colors-common vino gnome-orca adwaita-icon-theme-full info
sudo apt-get -o Dpkg::Options::="--force-confask" install --reinstall acpid libcompizconfig0 mate-menus systemd xdg-user-dirs-gtk vino casper # select Y

Then check system for files, that are not from Ubuntu repositories:

sudo find /bin /etc /lib /lib64 /opt /sbin /srv /usr /var -type f -exec dpkg -S {} \; 2> ~/Desktop/results.out

Remove the following objects (may be others!):

sudo rm -rf /etc/linuxmint
sudo rm -rf /usr/lib/linuxmint
sudo rm /usr/lib/python3/dist-packages/__pycache__/mintreport.cpython-38.pyc

And finally install Ubuntu MATE desktop on first login:

sudo apt-get install lightdm-gtk-greeter ubuntu-mate-lightdm-theme ubuntu-mate-themes ubuntu-mate-wallpapers* ubuntu-mate-core ubuntu-mate-default-settings ubuntu-mate-artwork ubuntu-mate-icon-themes plymouth-theme-ubuntu-mate-logo plymouth-theme-ubuntu-mate-text grub2-themes-ubuntu-mate mate-tweak ubuntu-mate-guide caja-eiciel compiz-mate eom mate-accessibility-profiles mate-applet-appmenu mate-applet-brisk-menu mate-calc mate-dock-applet mate-hud mate-menu mate-netbook mate-optimus mate-user-guide mate-window-applets-common mate-window-buttons-applet mate-window-menu-applet mate-window-title-applet folder-color-caja deja-dup-caja gsettings-ubuntu-schemas indicator-messages indicator-power indicator-session indicator-sound brasero shotwell simple-scan smbclient ubuntu-standard vlc gdebi gdebi-core plank seahorse tilda

Reset MATE desktop settings to the defaults:

dconf reset -f /org/mate
gsettings set org.mate.panel default-layout "'default'"

Install MATE Welcome and Software Boutique as Snaps:

sudo snap install software-boutique --classic
sudo snap install ubuntu-mate-welcome --classic

Reboot and have nearly normal Ubuntu Focal 20.04 LTS :)