To remove an installed .deb package on Ubuntu, you can do the following:
dpkg commandIf you know the name of the .deb package, you can use the dpkg command to remove it.
If you don't know the name of the package, use the command:
dpkg -l | grep <package-name-or-keyword>
After determining the exact name of the package, remove it with:
sudo dpkg -r <package-name>
Example:
sudo dpkg -r example-package
If you want to remove the package's configuration files as well:
sudo dpkg --purge <package-name>
apt (if the package was installed via apt)Sometimes .deb packages after installation will be managed by apt.
Check package name with:
dpkg -l | grep <keyword>
Use the following command to remove:
sudo apt remove <package-name>
sudo apt purge <package-name>
After removing the package, you can clean up unnecessary packages:
sudo apt autoremove
If you get an error similar to:
dpkg: warning: ignoring request to remove package which isn't installed, this means that the package you are trying to remove does not exist.
.deb file if necessaryIf you only want to remove the .deb file after installation, you can simply use the command:
rm path/to/package.deb
If the dpkg or apt command fails, you can try to fix it:
sudo apt --fix-broken install
Then run the uninstall command again.