If apt cannot remove it normally, you can force dpkg to purge the package entirely from the database.

Backup and rebuild:

(Debian Package) is the backend package management system for Debian-based Linux distributions. When you use user-friendly tools like apt (Advanced Packaging Tool) to install software (e.g., sudo apt install firefox ), apt is essentially a front-end that handles the downloading and dependency resolution. Once the files are downloaded, apt hands them over to dpkg to actually unpack and install the software onto your system.

sudo rm /var/lib/dpkg/lock-frontend sudo rm /var/lib/dpkg/lock sudo rm /var/lib/apt/lists/lock sudo rm /var/cache/apt/archives/lock

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

After the commands complete successfully, reboot to ensure no lingering processes: