Ubuntu Linux – How Do I install .deb Packages?

I am a new Ubuntu Linux user. How can I install a package called package.deb? Can I use Synaptic front-end package management tool to install packages from the CD or Internet such as apt command or apt-get command. However, I would like to install a special .deb file. How do I install .deb package from the terminal using command line option in Ubuntu Linux or Debian Linux?

Tutorial details
Difficulty Easy (rss)
Root privileges No
Requirements dpkg
Time 1m
You need to use the dpkg command or apt-get command/apt command, which is a package manager from shell/command prompt for Debian and Ubuntu Linux. You can use this tool to install, build, remove and manage packages. dpkg itself is controlled entirely via command line parameters.

How Do I install .deb Packages on an Ubuntu Linux?

The syntax is as follows to install .deb file via the command line:

dpkg -i package-name-here.deb
dpkg --install package-name-here.deb
dpkg -i -R /path/to/dir/name/with/lots/of/dot-deb-files/
dpkg -i --recursive /path/to/dir/name/with/lots/of/dot-deb-files/
####################################################################
## Attempt to correct a system with broken dependencies in place by 
## passing the '-f' option to the apt-get 
####################################################################
sudo apt-get install -f
## OR ##
sudo apt install -f

Where,

  1. -i or --install : Install the .deb package on Ubuntu Linux.
  2. -R or --recursive : Recursively installed all *.deb files found at specified directories and all of its sub-directories. /path/to/dir/name/with/lots/of/dot-deb-files/ must refer to a directory instead of package-name-here.deb file name.

Make sure you run the following command using the ‘sudo dpkg -i ./file.deb’ command which try to fix system by installing much needed and missing dependencies. From the man page

Fix; attempt to correct a system with broken dependencies in place. This option, when used with install/remove, can omit any packages to permit APT to deduce a likely solution. If packages are specified, these have to completely correct the problem. The option is sometimes necessary when running APT for the first time; APT itself does not allow broken package dependencies to exist on a system. It is possible that a system’s dependency structure can be so corrupt as to require manual intervention (which usually means using dpkg –remove to eliminate some of the offending packages). Use of this option together with -m may produce an error in some situations. Configuration Item: APT::Get::Fix-Broken.

How do I install .deb file on Ubuntu?

To install a single package file called /tmp/package.deb type the following commands. Open a terminal and then cd to directory where package.deb is kept. In this example, package.deb is kept in /tmp directory:
$ cd /tmp
Type the following command to install the package:
$ sudo dpkg -i package.deb
$ sudo apt-get install -f

OR as root user run:
# dpkg -i package.deb
# apt-get install -f

How do I install a atop_2.3.0-1_amd64.deb file via the bash command line?

Say you downloaded a deb file named atop_2.3.0-1_amd64.deb:
$ ls -l *.deb
To install .deb packages named atop_2.3.0-1_amd64.deb, run:
$ sudo dpkg -i ./atop_2.3.0-1_amd64.deb

Install all packages from /nfs/pkgs/ubuntu-builds directory

Recursively handle and install all regular files matching pattern *.deb found at /nfs/pkgs/ubuntu-builds/ directory and all of its subdirectories, type:
$ sudo dpkg -i -R /nfs/pkgs/ubuntu-builds/
OR
# dpkg -i -R /nfs/pkgs/ubuntu-builds/

A note about GUI tools

Open your file manager. Visit folder such as ~/Downloads/ or /tmp/. Choose .deb file. Double click on the .deb file and installation will start automatically. It works if you have a GUI installed on your system or server:

Next a dialog box comes on screen as follows:

Click on the Install button. You must authorized yourself to install software/.deb package file:

Once authenticated, .deb file install and you will see progress as follows:

Installing .deb package file using the apt command

The syntax is as follows:
$ sudo apt install ./file.deb
$ sudo apt install /path/to/file.deb
## install ALL *.deb file in the current dir ##
$ sudo apt install ./*.deb

Conclusion

You learned about installing deb package on an Ubuntu Linux using the dpkg command. For more info see the following pages:

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
71 comments… add one
  • Jim Juette Jul 1, 2014 @ 12:41

    Nice explanation and very simple instructions. I just installed the latest alpha of Kingsoft Office and it went as smoothly as can be expected for an alpha.

  • treegb Dec 24, 2014 @ 3:37

    I’m not sure if this method ( [dpkg -i … ] ) will going wrong.
    I saw someone use :
    dpkg -i
    then
    apt-get install -f
    because sometimes dependency go wrong with only the first command, then you have to use the second command to solve the dependency problem afterwards.

    My way is put the .deb file into [/var/cache/apt/archives] , and run [aptitude install ]. aptitude will check the local package in [/var/cache/apt/archives] , then install it.
    I not found the way to use aptitude to install .deb file directly yet. But I’m not sure whether these method is flawed, maybe someone can tell me.

  • helena Jan 1, 2015 @ 22:09

    helena@helena-SATELLITE-L750:~$ dpkg -i package-name-here.deb
    dpkg: error: requested operation requires superuser privilege
    helena@helena-SATELLITE-L750:~$ dpkg –install package-name-here.deb
    dpkg: error: requested operation requires superuser privilege
    helena@helena-SATELLITE-L750:~$ dpkg -i -R /path/to/dir/name/with/lots/of/dot-deb-files/
    dpkg: error: requested operation requires superuser privilege
    helena@helena-SATELLITE-L750:~$ dpkg -i –recursive /path/to/dir/name/with/lots/of/dot-deb-files/
    dpkg: error: requested operation requires superuser privilege
    helena@helena-SATELLITE-L750:~$
    helena@helena-SATELLITE-L750:~$

    how can I resolve this , thanks

  • Eduard Mar 1, 2015 @ 9:09

    Same as Sam….“dpkg: error processing *****.deb (–install):
    cannot access archive: No such file or directory
    Errors were encountered while processing:
    ******.deb”
    it seems that no one knows why…………

  • F-3000 Jun 2, 2015 @ 10:07

    Add sudo at the beginning.

  • Ed Jan 29, 2016 @ 18:37

    Neither the Terminal or any other form of “command line intervention” is required to install a .deb package in Ubuntu. A simple “double click” of the mouse is all that’s required to install a .deb package. The manner in which many “command line centric Linux enthusiasts” instruct main stream Ubuntu end-users to employ the terminal when far simpler “point and click, cut and paste or drag and drop” options are available to them, is both patently absurd and EXTREMELY misleading. The installation procedure is virtually identical to that of installing an application that’s been downloaded to Windows.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.