How to Uninstall or Remove Broken Package in Linux?

Many times it happens that when you try to uninstall a package you encounter an error and the package cannot be uninstalled. This happens when the package is broken. To overcome this issue, we remove the post files of the package to make things work. in this article we are going to learn how to Remove Broken Package in Linux.

Recently, I was trying to remove the ImunifyAV package but encountered this error. E: Sub-process /usr/bin/dpkg returned an error code (1)

Uninstallation Error

Removing the Post Files

To fix this issue and remove the package successfully, we need to remove the post files manually for this package. But first, we need to see the files for this package. The installation files are usually located at /var/lib/dpkg/info file. Type in the following command and replace the package_name with the name of the package that you want to remove.

How to download Anydesk and how to install Anydesk

sudo ls -l /var/lib/dpkg/info | grep package_name
Remove Broken Package in Linux

In my case, I replaced the package_name with imunify-antivirus. This thing helps me to list all packages of imunify-antivirus. Now we need to remove these files manually. For that, type the command:

sudo mv /var/lib/dpkg/info/package_name.* /tmp

This will move all the post files to the tmp directory in case we need them back for any reason. Once the command executed to remove files. After doing that reinstall the package again without getting any errors.

Don’t forget to run the sudo apt update command after removing the files.

after doing all these just run commands to Remove Broken Package in Linux.

Command to Remove Broken Package in Linux:

$ apt unintsall <package-name> 

After doing all these steps you can run the uninstall command like this given above and get the required results.

Here you can read How to log in to the Rainloop admin dashboard?

Read More: How to Change Upload limit On CyberPanel?

How to Change Upload limit On CyberPanel?

You can follow us on Facebook too.