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?
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.
You can install it using sudo dpkg -i /path/to/deb/file followed by sudo apt-get install -f.
You can install it 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.
Install gdebi and open your .deb file using it (Right-click -> Open with). It will install your .deb package with all its dependencies.
Why to use sudo apt-get install -f after sudo dpkg -i /path/to/deb/file (mentioned in first method).
When dpkg install a package and package dependency is not satisfied, it leaves the package in unconfigured state and that package is considered as broken.
sudo apt-get install -f command tries to fix this broken package by installing the missing dependency.
Install your foo.deb file with dpkg -i foo.deb. If there are some errors with unresolved dependencies, run apt-get install -f afterwards.
If you don't have gdebi installed already, install it using sudo apt install gdebi-core.
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.
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.
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.
Modern apt-get can be used to install a package simply with apt-get install /path/to/package/name.deb.
It is very simple if I want to install Chrome.
After giving the above command, dependencies will be added to your machine and your Debian package (.deb) file will be installed.
Not the answer you're looking for? Browse other questions tagged software-installation apt dpkg deb or ask your own question.
How can I automatically fetch dependencies when installing a Debian package?
Why can't sudo apt install locate a deb file?