How to Fix Broken Packages in Ubuntu
How to Fix Broken Packages in Ubuntu

Apt, Ubuntu’s package manager, is among the most powerful and intuitive, but that doesn’t mean that things can’t go wrong. Occasionally, a package install goes wrong on Ubuntu, and you’re left to pick up the pieces. It’s a good thing Ubuntu’s package utilities, including Apt itself, have built-in functionality to help remedy the situation and get things back to normal.
These tips and tricks should help you get unstuck in most instances. They’re all fairly universal, but every situation is different, so keep that in mind when trying to debug your own situation.
Related: How to Fix Ubuntu Update Errors
With Apt/Apt-Get
Apt has a couple of flags that you can use in order to fix missing dependencies or packages that broke for one reason or another during install. A common use here would be installing a third-party .deb and finding that it had dependencies you didn’t know about. Those dependencies probably won’t be pulled in on their own, and dpkg will complain that the package is missing in them. In any case, you can try these steps.

First, run an update to make sure that there aren’t newer versions of the required packages.
sudo apt update --fix-missing
Next, you can try forcing Apt to look for and correct any missing dependencies or broken packages. This will actually install any missing packages and repair existing installs.
sudo apt install -f
With DPKG
Another place where error can pop up in package installations is the configuration process. Behind the scenes, dpkg is taking care of this part, not Apt, so it would stand to reason that when a package fails during configuration, dpkg is the tool to turn to in order to fix it.

Start by trying to force dpkg to reconfigure any broken or partially configured packages.
sudo dpkg --configure -a
If that doesn’t solve the problem, you can take a more forceful approach. Start by listing any packages that dpkg marked as requiring a reinstall.
sudo dpkg -l | grep ^..r
You should see the problematic package(s) there. As long as there’s nothing that seems not to belong there, you can force-remove the broken packages.
sudo dpkg --remove --force-remove--reinstreq
When dpkg is done, try to clean up with Apt.
sudo apt clean
sudo apt update
With any luck that’ll get you back to where you started. It won’t get you the broken packages that you tried to install, but at least Apt will be functional again.
Related: Ubuntu Software Center Not Working? Here Are the Fixes
Permanent DPKG Lock

There’s a less common issue with ridiculous dpkg locks preventing you from doing anything. Every time you try to use Apt or dpkg, you get an error saying another application already is … when it isn’t. It’s actually easy to delete the lock file preventing you from using Apt and get back to doing what you need to. Sometimes these lock files remain in place after an error occurs in an install, derailing the process and preventing the file from being removed automatically. In this case, you’ll need to do it yourself.
sudo rm /var/lib/apt/lists/lock
For good measure, delete the lock in cache.
sudo rm /var/cache/apt/archives/lock
Conclusion
Hopefully, one of these fixes worked for you, and you’re back working on Ubuntu normally. Remember that the best way to handle a totally out-of-hand situation is to try to return to the way it was before. Don’t try to power through and add more things to solve a breakage by adding more things, unless you know exactly what you’re doing. Chances are you’ll end up with a tangled mess of broken things that’ll be harder to sort out.
How to Fix Broken Packages in Ubuntu的更多相关文章
- How to fix broken packages?(转)
Try Code: sudo apt-get update to update your package list.Then Code: sudo apt-get autoclean to clean ...
- 解决 E: Unable to correct problems, you have held broken packages. 问题
参考: Unable to correct problems, you have held broken packages 环境 Ubuntu 14.04, 64bit 问题 在安装gcc-4.9的时 ...
- ubuntu 'Unable to correct problems, you have held broken packages' 错误
在用apt 安装软件时,有时会用国内的源以加快下载速度. 但是在使用ubuntu 14.04的过程中,这一过程可能会导致错误“Unable to correct problems, you have ...
- Fix catalyst driver in Ubuntu 13.04 / 13.10
Fix catalyst driver in Ubuntu 13.04 / 13.10(墙外文章备份) 1. Introduction I found lots of people strugglin ...
- E: Unable to correct problems, you have held broken packages 解决方法
在Ubuntu中安装软件的时候经常碰到E: Unable to correct problems, you have held broken packages.的错误,顾名思义是因为某些软件包冲突导致 ...
- E: Unable to correct problems, you have held broken packages
问题: apt install libmysqlclient-dev Reading package lists... DoneBuilding dependency tree Readi ...
- ubuntu16 安装openssh-server 一直安装不上Unable to correct problems, you have held broken packages
zengqi@zengqi:~$ sudo apt-get install openssh-server Reading package lists... DoneBuilding dependenc ...
- 如何解决Ubuntu下的“E: Unable to correct problems, you have held broken packages.”的问题. aptitude
今天安装build-essential时出现了以下问题,这属于包的依赖. 解决方案: 1,sudo apt-get install aptitude:完成aptitude命令安装 2,sudo apt ...
- Unable to correct problems, you have held broken packages
Use aptitude instead of apt-get. It is more intelligent. It not only will handle downgrading conflic ...
随机推荐
- C之volatile
https://blog.csdn.net/vay0721/article/details/79035854 https://blog.csdn.net/kaychangeek/article/det ...
- Scrapy框架1——简单使用
一.设置与编写 打开cmd,选择好路径 1.创建项目scrapy startproject projectname d:\爬虫\11.scrapy>scrapy startproject tes ...
- svn: E230001: Server SSL certificate verification failed: certificate issued
svn: E230001: Server SSL certificate verification failed: certificate issued 今天在使用svn时候发现出现这个问题,这个是因 ...
- xml文件中引用网址报红色如何解决
用了ideal的宝宝们一定遇到过配置文件网址报红的错误吧 其实解决很简单,就是网不好导致它没法补全,我们手动给他补全就好啦 复制报红的网址 点击File==>settings==>lang ...
- oracle给用户授权存储过程
https://www.jianshu.com/p/fab356d68ae2 grant connect,resource to xinomonitor; 发现不能进行断点调试,然后授如下权限 gra ...
- Luogu5290 [十二省联考2019] 春节十二响 【贪心】【堆】
题目分析: 对于一个根,假设我们对每个子树分别求出了一种答案,那么怎么合并答案是最小的呢? 首先考虑这些答案里面最大的那个数字,它肯定要融合其它组里面的最大数字.以此类推 所以最好的合并方式是,每个子 ...
- 自定义AuthorizeFilter
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization.Infrastructure; u ...
- C++ 基础知识汇总 持续更新
摘录一些C++面试常考问题,写一些自己的理解,花了挺长时间的,作图是真的累,欢迎来摘果子. static关键字 用于声明静态对象: 静态函数只在本文件可见.(默认是extern的) 全局静态对象:全局 ...
- Linux安全:Linux如何防止木马
(一)解答战略 去企业面试时是有多位竞争者的,因此要注意答题的维度和高度,一定要直接秒杀竞争者,搞定高薪offer. (二)解答战术 因为Linux下的木马常常是恶意者通过Web的上传目录的方式来上传 ...
- SQLSEVER 同台服务器下不同表 触发器实现数据实时同步
触发器的使用: 1.首先建立两个相同结构的表,两个表明的列的名称不同. student_01 字段 name ; 字段 age ; 字段 class ; student_02 字段 ...