apt -f install 命令的意义

通常在用dpkg -i 命令安装了一个deb包之后,如果执行apt upgrade,有时候会遇到错误提示。

这种情况下,如果在dpkg -i安装了deb包之后马上执行apt -f install命令,好像会好一些。

我查了一下apt-get(8)[apt-get(8) — apt — Debian buster — Debian Manpages],只提到了修复有问题的包。

我的问题是,通常并不建议使用dpkg -i命令来安装包;那么apt -f install命令是否可以让dpkg -i命令更好用,或者说,dpkg -i命令加上apt -f install命令一起用,是不是会让依赖问题出现的概率更小一些?


apt install ./xx.deb

2 个赞



1 个赞


If the package to install has been made available to you under the form of a simple .deb file without any associated package repository, it is still possible to use APT to install it together with its dependencies (provided that the dependencies are available in the configured repositories) with a simple command: apt install ./path-to-the-package.deb. The leading ./ is important to make it clear that we are referring to a filename and not to the name of a package available in one of the repositories.


dpkg -i <package_name>-<debian_version>.deb
apt install /path/to/<package_filename>.deb


系统管理员应该小心使用低级的软件包工具(例如 “dpkg -i …” 和 “debi …”),它们不会自动处理所需的软件包依赖。 dpkg 的命令行选项 “--force-all” 和类似的选项(参见 dpkg(1))只适用于高手。没有完全理解它们的效果却使用它们会破坏你的整个系统。


There are two ways a system can get into a broken state like this. The first is caused by dpkg missing some subtle relationships between packages when performing upgrades. The second is if a package installation fails during an operation. In this situation a package may have been unpacked without its dependents being installed.
The second situation is much less serious than the first because APT places certain constraints on the order that packages are installed. In both cases supplying the -f option to apt-get will cause APT to deduce a possible solution to the problem and then continue on. The APT dselect method always supplies the -f option to allow for easy continuation of failed maintainer scripts.
However, if the -f option is used to correct a seriously broken system caused by the first case then it is possible that it will either fail immediately or the installation sequence will fail. In either case it is necessary to manually use dpkg (possibly with forcing options) to correct the situation enough to allow APT to proceed.

总结:建议安装本地deb软件包时使用命令apt install ./path-to-the-package.deb

1 个赞