Installing and removing packages on Linux operating systems like Ubuntu is smooth and easy, but it gets complicated if you get errors due to broken packages.

Whether you can’t install or remove a package, this guide is for you and it will work on Ubuntu, Linux Mint, Kali, Fedora, CentOS, and other Linux distributions.

Contents show

1 Causes of Broken Packages on Linux Operating Systems (Ubuntu and Others)

2 How To Fix Broken Packages In Ubuntu and Debian-Based Distributions?

2.1 1. Clean the Package
2.2 2. Reinstall Broken Packages Ubuntu (APT)
2.3 3. Use DPKG to Force Remove the Broken Packages
2.4 4. Solve the Lock Issue
2.5 5. Auto Clean Broken Packages
2.6 6. Fix Broken Files in Recovery Mode
2.7 7. Repair Broken System Package
2.8 8. Try Synaptic Package Manager

3 Fixing Broken Packages on Fedora, CentOS, and More Red Hat Enterprises Linux (RHEL)

4 How To Avoid Broken Packages in Ubuntu and Debian-Based Distros?

5 Conclusion

Causes of Broken Packages on Linux Operating Systems (Ubuntu and Others)

The package installed partially Dependency or repository error A new update interrupting the installation Something in the package is conflicting with something else on your system The package was removed incorrectly

How To Fix Broken Packages In Ubuntu and Debian-Based Distributions?

    Clean the Package Reinstall Broken Packages Ubuntu (APT) Use DPKG to Force Remove the Broken Packages Solve the Lock Issue Auto Clean Broken Packages Fix Broken Files in Recovery Mode Repair Broken System Package Try Synaptic Package Manager

1. Clean the Package

If you know exactly which package is causing the trouble, fixing broken packages in Ubuntu is pretty easy. You can remove the package and clean the disk space.

Open the Terminal by pressing Ctrl + Alt + T on your keyboard and hitting the Enter key. Begin with cleaning the cache of the package with this command: sudo rm -rf /var/cache/apt/archives/[package-name] For example, to clean cache files of the Chrome package, try the command sudo rm -rf /var/cache/apt/archives/google-chrome-stable_current_amd64.deb Enter your sudo account password After this, free the storage space and then update the repository with these commands: sudo apt-get autoclean

8 best fixes for broken packages in ubuntu
sudo apt-get update sudo apt-get upgrade

Furthermore, another way to do this is by moving the cache files of the package to the temporary files. Then, remove the broken package using the Debian Package Manager (dkpg). (The following command is moving and removing RVM.)

sudo mv /var/lib/dpkg/info/rvm.* /tmp/ sudo dpkg –remove –force-remove-reinstreq rvm

2. Reinstall Broken Packages Ubuntu (APT)

Knowing which package is broken on your Linux system is not always the case. So, try this method to make your system check for missing updates, update the packages’ list, and then force install the broken packages.

Press Ctrl + Alt + T to open the Terminal. Find missing updates by using the command. It will take some time to check and fix updates. sudo apt –fix-missing update

8 best fixes for broken packages in ubuntu
When it’s done, it’s time to update the list of packages from the available sources. sudo apt update Now, use the -f flag in the next command to force install broken packages. Ubuntu will look for any broken package and force install it. sudo apt install -f

3. Use DPKG to Force Remove the Broken Packages

If you face a problem using the APT package management system to remove troublesome packages, use the dpkg package management system instead.

This is useful if you need to force remove the packages. This is because sometimes the packages are installed in the root directory. 

Open the terminal shell and use the below steps:

Force the dpkg system to reconfigure the packages that are unpacked but haven’t been configured. As I’m trying to configure all packages using the -a flag. sudo dpkg –configure -a Get the list of all the packages marked as required by dpkg. sudo dpkg -l | grep ^..r Now that you have the list of the required packages, delete all the broken packages. Replace [package-name] with the package you want to remove. sudo dpkg –remove –force-remove-reinstreq [package-name]

8 best fixes for broken packages in ubuntu
Perform cleanup of the package. sudo apt clean Update the packages’ list from the available sources sudo apt update
8 best fixes for broken packages in ubuntu
sudo apt update –fix-missing update Run the below command to see which packages were installed. $ sudo apt-get install -f

4. Solve the Lock Issue

The dpkg lock issue is not common but it stops you from performing any action. You can access the apt and dpkg package management systems.

Whenever you do, there is an error stating that the file is being used by another file or tool.

The reason for this problem is that during installation, some packages are stored in the filesystem as archive. They show errors when you try to remove them.

Usually, when you remove something from your Ubuntu system, all of its plugins and dependency files are also removed. But some files don’t due to the above-mentioned reason and cause issues.

Get root access and remove the troublesome files:

sudo rm /var/lib/apt/lists/lock sudo rm /var/cache/apt/archives/lock

5. Auto Clean Broken Packages

This method doesn’t remove the broken packages Ubuntu, instead, it cleans the temporary files left by packages upon removal.

Many packages leave some of their files on your filesystem when removed so that if the user decides to install the app again, the process is quicker. We’ll be cleaning those files.

Clean unused space and wipe cache files sudo apt-get autoclean sudo apt-get clean

8 best fixes for broken packages in ubuntu
Remove unnecessary files and dependency data by using root access and the below command sudo apt-get autoremove
8 best fixes for broken packages in ubuntu
After the removal, update the list of the installed packages sudo apt-get update
8 best fixes for broken packages in ubuntu

6. Fix Broken Files in Recovery Mode

This is an effective method of repairing broken packages in Ubuntu which is not commonly used. It, technically, doesn’t fix broken files, but it performs repairs that also solve the issue of broken packages. Duplicate the below steps:

To enter recovery mode, turn on your Ubuntu system. After seeing the manufacturer’s logo, immediately press and hold the Shift key on your keyboard until some options appear on the black (BIOS) screen. Select ‘Advanced options for Ubuntu’.

8 best fixes for broken packages in ubuntu
Then, pick ‘Ubuntu, with Linux……. (Recovery Mode)’.
8 best fixes for broken packages in ubuntu
When the recovery menu appears, select dpkg and press enter.
8 best fixes for broken packages in ubuntu
It will ask to remount your filesystem in read/write mode. Select ‘Yes’.
8 best fixes for broken packages in ubuntu
Once it’s done with its process, it may ask for an upgrade if available. Type yN to continue.

7. Repair Broken System Package

Software Updater is responsible for keeping your Ubuntu system updated. Any dependency or system error can cause broken system packages, which will stop the software updater application from working properly.

To get rid of this error, wipe the system cache and clean the filesystem.

sudo apt-get clean sudo apt-get install -f

8 best fixes for broken packages in ubuntu

8. Try Synaptic Package Manager

It’s a GUI-based package manager that is easy to use and can install, remove, update, and fix broken packages Ubuntu.

For installing Synaptic Package Manager, use these commands that require root access:

sudo apt-get update sudo apt-get install synaptic

8 best fixes for broken packages in ubuntu
Upon confirmation, press Y and hit the Enter key. After the installation, run it by clicking ‘Activities’, typing ‘synaptic package manager’, and opening the app.
8 best fixes for broken packages in ubuntu
Checkmark the package that is broken. Then, click ‘Edit’ on the menu bar and pick ‘Fix broken packages’.
8 best fixes for broken packages in ubuntu
Upon repairing the package, use any of the above-mentioned methods to remove the package.

Fixing Broken Packages on Fedora, CentOS, and More Red Hat Enterprises Linux (RHEL)

Usually, yum and dnf do a good job of keeping the packages clean on RHEL operating systems, but some apps cause broken packages anyway.

For rpm-based systems, use the following command. sudo rpm -Va This will give you a list of installed files in the rpm database. After this, you can check for any suspicious packages and apply the below command. sudo dnf –refresh reinstall [package-name] The above command will set the metadata as expired and may help you find broken dependencies with that package and will suggest using the –skip-broken flag. 

How To Avoid Broken Packages in Ubuntu and Debian-Based Distros?

Fixing broken packages in Ubuntu takes time so it’s better to prevent this in the first place by cleaning and removing the repository files of the programs that you have removed.

Open ‘Software and Updates’. Switch to the ‘Other Software’ tab. It will have the repository list. Select any to remove.

8 best fixes for broken packages in ubuntu

Conclusion

Finding and repairing or removing broken packages on Ubuntu is a bit complicated, but with the various methods above, you can select the right one for you and keep your Ubuntu system clean and without errors.

TECH NEWS RELATED

How To Snip Screen On Your Laptop?

Taking a screenshot is not a complicated process. All of us are familiar with at least one way to do it. However, there are several ways to capture your screen for a frame. We made this article to show you all the different ways you can grab your screens. If ...

View more: How To Snip Screen On Your Laptop?

How To Connect AirPods To A Laptop?

The Apple AirPods are, undoubtedly, some of the best earpieces available on the electronics market. With three generations of different AirPods models, these sleek, ivory earphones are quite popular. Apart from the appearance and quality, AirPods are known for being versatile. Irrespective of what the host device is, AirPods can ...

View more: How To Connect AirPods To A Laptop?

7 Best Ways To Fix DistributedCOM Error In Windows

If you open the Event Viewer utility often, you may notice a DistributedCOM Error on Windows. Let’s know what this DistributedCOM Error Windows error is, how it’s caused, and how you can fix it. Contents show 1 What Is the DistributedCOM Error Windows 10 and 11? 2 What is the ...

View more: 7 Best Ways To Fix DistributedCOM Error In Windows

12 Easy Fixes For Webcam Not Working In Windows

Cameras are becoming quite common for PCs. We use meetings on Zoom, Microsoft Teams, Skype, and other options. The operating system might not be at fault if your camera isn’t working. You can use the given solutions to solve the Webcam Not Working Windows issue quickly. We have covered ...

View more: 12 Easy Fixes For Webcam Not Working In Windows

Windows 10 Sound Not Working: 18 Quick And Easy Methods

Is  Windows 10 Sound Not Working on your PC? This is a common issue faced by many Windows users.  If you are one among them, you are in the right place. This article gives you 11 solutions to fix the no-sound issues in Windows 10.  Contents show 1 Reasons For ...

View more: Windows 10 Sound Not Working: 18 Quick And Easy Methods

How Can You See If Someone Is Not Following You On Facebook: 2 Easy Methods

Facebook is one of the most popular social media platforms used by many. It allows users to find people worldwide and connect with them, share their thoughts, and so on.  But sometimes your opinions and posts may not be welcomed by everyone and there is a chance that they may ...

View more: How Can You See If Someone Is Not Following You On Facebook: 2 Easy Methods

How To Fix This Update Is Not Applicable To Your Computer Error: 11 Quick Fixes

Windows standalone updates packages are useful when your Windows updater is not working or you want to install a certain update manually. However, running these updated packages, sometimes, shows the error message “This update is not applicable to your computer” or “This update is not applicable to your computer”. ...

View more: How To Fix This Update Is Not Applicable To Your Computer Error: 11 Quick Fixes

Windows Dual Boot Menu Not Showing: 6 Easy Ways To Fix

Users who install multiple Windows on their computer see a boot menu when they turn on the PC to select the operating system they want to boot up. But due to various reasons, the boot menu also called the “Choose an operating system” menu may not appear causing Windows Dual ...

View more: Windows Dual Boot Menu Not Showing: 6 Easy Ways To Fix

12 Best Fixes: Windows 10 Start Menu Search Not Working

Windows Encryption Not Working? 6 Best Ways To Fix

Windows Update Error 0x80073701: 9 Best Ways To Fix

Best Ways To Fix Slow Internet During VPN On Windows 11

Best free sports streaming apps in 2023

6 Solutions To Fix Wmpnetwk High CPU Usage In Windows

9 Best Fix: Windows Won’t Recognize Android Device

18 Best Ways To Fix Windows Infinite Reboot Loop

How To Fix Windows and Linux Showing Different Times When Dual Booting

11 Solutions To Fix The Windows XP iertutil.dll Errors

8 Best Smart Home Automation Apps for Android and iOS

No Sound on Windows 11? Here Are 6 Ways How to Fix It!

OTHER TECH NEWS

Top Car News Car News