Unix & Linux: How to install a deb file, by dpkg -i or by apt? (7 Solutions!!)

Published: 06 August 2020
on channel: Roel Van de Paar
1,696
29

Unix & Linux: How to install a deb file, by dpkg -i or by apt?


The Question: 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?

Solutions: Please watch the whole video to see all solutions, in order of how many people found them helpful

== This solution helped 15 people ==
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 my.deb in /var/cache/apt/archives and install it
directly with apt-get but I never tried. Doesn't work, apt-get and dpkg are
looking for packages listed in archives.

== This solution helped 97 people ==
Install your foo.deb file with dpkg -i foo.deb. If there are some errors with
unresolved dependencies, run apt-get install -f afterwards.

== This solution helped 989 people ==
When you use apt to install a package, https://wiki.debian.org/
DebianPackageManagement 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: ***
1. Using:
sudo dpkg -i /path/to/deb/file
sudo apt-get install -f
2. Using:
sudo apt install ./name.deb
Or
sudo apt install /path/to/package/name.deb
With old apt-get versions 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.
3. First installing gdebi and 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 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.
----
**** Why use sudo apt-get install -f after sudo dpkg -i /path/to/deb/file (as
mentioned in method 1)? ****
From man apt-get:
-f, --fix-broken
Fix; attempt to correct a system with broken dependencies in place.
When 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.
The sudo apt-get install -f command tries to fix this broken package by
installing the missing dependency.

== This solution helped 6 people ==
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.

With thanks & praise to God, and with thanks to the many people who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music: https://www.bensound.com/royalty-free... | Images: https://stocksnap.io/license & others | With thanks to user wisbucky (https://unix.stackexchange.com/users/..., user Tim (https://unix.stackexchange.com/users/..., user sk8forether (https://unix.stackexchange.com/users/..., user reducing activity (https://unix.stackexchange.com/users/..., user Interesting... (https://unix.stackexchange.com/users/..., user ihor_dvoretskyi (https://unix.stackexchange.com/users/..., user g_p (https://unix.stackexchange.com/users/..., user Flimm (https://unix.stackexchange.com/users/..., user Alex (https://unix.stackexchange.com/users/..., and the Stack Exchange Network (http://unix.stackexchange.com/questio.... Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything is amiss at Roel D.OT VandePaar A.T gmail.com.


Watch video Unix & Linux: How to install a deb file, by dpkg -i or by apt? (7 Solutions!!) online without registration, duration hours minute second in high quality. This video was added by user Roel Van de Paar 06 August 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 1,696 once and liked it 29 people.