How to install a deb file, by dpkg -i or by apt?
I have a deb package for installation.
Shall I install by
dpkg -i my.deb, or by apt?
Will both handle the software dependency problem well?
If by apt, how can I install from the deb by apt?
Check the dependencies with
dpkg -I my.deb and
apt-get install the dependencies before
dpkg -i my.deb.
May be you can copy the
/var/cache/apt/archives and install it directly with
apt-get but I never tried.
dpkg are looking for packages listed in archives.
foo.deb file with
dpkg -i foo.deb. If there are some errors with unresolved dependencies, run
apt-get install -f afterwards.
When you use
apt to install a package, under the hood it uses
dpkg. When you install a package using apt, it first creates a list of all the dependencies and downloads it from the repository.
Once the download is finished it calls
dpkg to install all those files, satisfying all the dependencies.
So if you have a
.deb file, you can install it by:
sudo dpkg -i /path/to/deb/file sudo apt-get install -f
sudo apt install ./name.deb
sudo apt install /path/to/package/name.deb
apt-getversions you must first move your deb file to
/var/cache/apt/archives/directory. For both, after executing this command, it will automatically download its dependencies.
gdebiand then opening your .deb file using it (Right-click -> Open with). It will install your .deb package with all its dependencies.
Note: APT maintains the package index which is a database (
/var/cache/apt/*.bin) of available packages available in repo defined in
/etc/apt/sources.list file and in the
/etc/apt/sources.list.d directory. All these methods will fail to satisfy the software dependency if the dependencies required by the deb is not present in the package index.
sudo apt-get install -f after
sudo dpkg -i /path/to/deb/file (as mentioned in method 1)?
-f, --fix-broken Fix; attempt to correct a system with broken dependencies in place.
dpkg installs a package and a package dependency is not satisfied, it leaves the package in an "unconfigured" state and that package is considered broken.
sudo apt-get install -f command tries to fix this broken package by installing the missing dependency.
The simplest answer would be to use dpkg by running
dpkg -i packagename.deb. You could then uninstall it by running
dpkg -r packagename.deb.
apt-get is a higher level installer based off of dpkg, and as such you could
apt-get install packagename.deb.
It would be beneficial for add it to your apt-get archives directory (
/var/cache/apt/archives) so you could reference it as a package with dependencies and not a standalone .deb archive.
Also, by adding it to your apt-get archives directory, you have the opportunity to use dependencies with
apt-get install packagename. This would let you install it with any manually added dependencies instead of dpkg’s standalone archive-based system.
Here’s the best way to install a
.deb file on Ubuntu on the command-line:
sudo gdebi skype.deb
If you don’t have
gdebi installed already, install it using
sudo apt install gdebi-core.
gdebi will look for all the dependencies of the
.deb file, and will install them before attempting to install the
.deb file. I find this much preferable than
sudo dpkg -i skype.deb && sudo apt install -f. The latter is much too eager to remove dependencies in certain situations. For instance, when I tried to install Skype, it attempted to remove 96 (!) packages, including packages like
gdebi gave a much clearer error message:
$ sudo gdebi skype.deb Cannot install 'libqtgui:i386'
(Here is the solution to that particular issue, by the way.)
You can install a local .deb package by:
sudo apt install ./foo.deb
Make sure to specify a local relative or absolute path (
./ if in current dir), otherwise it will look for
foo.deb in the remote repos and fail.
Modern apt-get can be used to install a package simply with
apt-get install /path/to/package/name.deb.
(should be done as edit to the top answer but it was rejected – see https://unix.stackexchange.com/posts/159114/edit)
It is very simple if I want to install Chrome.
Install your Chrome file as:
dpkg -i googlechrome.deb.
Sometimes there is a chance of getting some dependency errors like the following:
dpkg: dependency problems prevent configuration of google-chrome-stable: google-chrome-stable depends on libappindicator1; however: Package libappindicator1 is not installed.
So to resolve above issues, you need to add dependencies; give the following command:
apt-get install -f
After giving the above command, dependencies will be added to your machine and your Debian package (
.deb) file will be installed.
The shortest way to install a local package with all required dependencies that worked for me:
sudo apt --fix-broken install ./name.deb
--fix-broken option that makes dependencies to be installed.