Uninstall package.deb

To remove an installed .deb package on Ubuntu, you can do the following:


1. Use the dpkg command

If you know the name of the .deb package, you can use the dpkg command to remove it.

Check the name of the installed package

If you don't know the name of the package, use the command:

dpkg -l | grep <package-name-or-keyword>

Uninstall a package

After determining the exact name of the package, remove it with:

sudo dpkg -r <package-name>

Example:

sudo dpkg -r example-package

Remove all configuration files (optional)

If you want to remove the package's configuration files as well:

sudo dpkg --purge <package-name>

2. Using apt (if the package was installed via apt)

Sometimes .deb packages after installation will be managed by apt.

Find package name

Check package name with:

dpkg -l | grep <keyword>

Remove package

Use the following command to remove:

sudo apt remove <package-name>

Remove package completely (including configuration)

sudo apt purge <package-name>

Remove unnecessary packages (dependencies)

After removing the package, you can clean up unnecessary packages:

sudo apt autoremove

3. Troubleshooting "package not installed" errors

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.


4. Delete the .deb file if necessary

If you only want to remove the .deb file after installation, you can simply use the command:

rm path/to/package.deb

5. Troubleshooting if you run into problems

If the dpkg or apt command fails, you can try to fix it:

sudo apt --fix-broken install

Then run the uninstall command again.