dpkg commands to manage packages on Debian Based Systems

dpkg stands for Debian package manager (dpkg). dpkg is a command-line tool to install, build, remove and manage Debian packages. dpkg uses Aptitude (primary and more user-friendly) as a front-end to perform all the actions.

Other utility such as dpkg-deb and dpkg-query uses dpkg as a front-end to perform some action.

Now a days most of the administrator using Apt, Apt-Get & Aptitude to manage packages easily without headache and its robust management too.

Even though still we need to use dpkg to perform some software installation where it’s necessary. Some other package manger utilities which are being used widely in Linux are yum, dnf, apt-get, dpkg, rpm, Zypper, pacman, urpmi, etc.,

Now, i’m going to play on our Ubuntu 15.10 box to explain and cover mostly used dpkg commands with examples.

1) Common syntax/file location for dpkg

See below for common syntax/ file location of dpkg which will help you if you want to check more about it.

[General syntax for dpkg]
$ dpkg -[command] [.deb package name]

$ dpkg -[command] [package name]

[dpkg releated files location]
$ /var/lib/dpkg

[This file contain modified package info by dpkg command like (install, remove, etc..,)]
$ /var/lib/dpkg/status

[This file contain available package list]
$ /var/lib/dpkg/status

2) Install/Upgrade the package

Use the below command to install/upgrade .deb packge on Debian based systems such as Debian, Mint, Ubuntu & elementryOS, etc..,. Here i’m going to install Atom through atom-amd64.deb file. It will upgrade if it’s installed other wise install a fresh one.

[Install/Upgrade dpkg packages]
$ sudo dpkg -i atom-amd64.deb
Selecting previously unselected package atom.
(Reading database ... 426102 files and directories currently installed.)
Preparing to unpack atom-amd64.deb ...
Unpacking atom (1.5.3) over (1.5.3) ...
Setting up atom (1.5.3) ...
Processing triggers for gnome-menus (3.13.3-6ubuntu1) ...
Processing triggers for bamfdaemon (0.5.2~bzr0+15.10.20150627.1-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for desktop-file-utils (0.22-1ubuntu3) ...
Processing triggers for mime-support (3.58ubuntu1) ...

3) Install a package from folder

Use the below command to install the packages recursively from directory on Debian based systems such as Debian, Mint, Ubuntu & elementryOS, etc,. This will install all the *.deb packages under the /opt/software directory.

$ sudo dpkg -iR /opt/software
Selecting previously unselected package atom.
(Reading database ... 423303 files and directories currently installed.)
Preparing to unpack /opt/software/atom-amd64.deb ...
Unpacking atom (1.5.3) ...
Setting up atom (1.5.3) ...
Processing triggers for gnome-menus (3.13.3-6ubuntu1) ...
Processing triggers for bamfdaemon (0.5.2~bzr0+15.10.20150627.1-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for desktop-file-utils (0.22-1ubuntu3) ...
Processing triggers for mime-support (3.58ubuntu1) ...

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...

Close
Please support the site
By clicking any of these buttons you help our site to get better