dpkg and dpkg-reconfigure commands

15 Practical Examples of “dpkg commands” for Debian Based Distros

Debian GNU/Linux, the mother Operating System of a number of Linux distributions including Knoppix, Kali,Ubuntu, Mint, etc. uses various package Manager like dpkg, apt, aptitude, synaptic, tasksel, deselect, dpkg-deband dpkg-split.

dpkg Command Examples

We will be describing each of these briefly before focusing on ‘dpkg‘ command.

APT Command

Apt stands for Advanced Package Tool. It doesn’t deal with ‘deb‘ package and works directly, but works with ‘deb‘ archive from the location specified in the “/etc/apt/sources.list” file.

Read More : 25 Useful Basic Commands of APT-GET Commands

Aptitude

Aptitude is a text based package manager for Debian which is front-end to ‘apt‘, which enables user to manage packages easily.

Synaptic

Graphical package manager which makes it easy to install, upgrade and uninstall packages even to novice.

Tasksel

Tasksel lets the user to install all the relevant packages related to a specific task, viz., Desktop-environment.

Deselect

A menu-driven package management tool, initially used during the first time install and now is replaced withaptitude.

Dpkg-deb

Interacts with Debian archive.

Dpkg-split

Useful in splitting and merging large file into chunks of small files to be stored on media of smaller size likefloppy-disk.

Dpkg Command

dpkg is the main package management program in Debian and Debian based System. It is used to install, build,remove, and manage packages. Aptitude is the primary front-end to dpkg.

Some the most commonly used dpkg commands along with their usages are listed here:

1. Install a Package

For installing an “.deb” package, use the command with “-i” option. For example, to install an “.deb” package called “flashpluginnonfree_2.8.2+squeeze1_i386.deb” use the following command.

[root@tecmint~]# dpkg -i flashpluginnonfree_2.8.2+squeeze1_i386.deb
Selecting previously unselected package flashplugin-nonfree.
(Reading database ... 465729 files and directories currently installed.)
Unpacking flashplugin-nonfree (from flashplugin-nonfree_3.2_i386.deb) ...
Setting up flashplugin-nonfree (1:3.2) ...
--2013-10-01 16:23:40--  http://fpdownload.macromedia.com/get/flashplayer/pdc/11.2.202.310/install_flash_player_11_linux.i386.tar.gz
Resolving fpdownload.macromedia.com (fpdownload.macromedia.com)... 23.64.66.70
Connecting to fpdownload.macromedia.com (fpdownload.macromedia.com)|23.64.66.70|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6923724 (6.6M) [application/x-gzip]
Saving to: ‘/tmp/flashplugin-nonfree.FPxQ4l02fL/install_flash_player_11_linux.i386.tar.gz’

2. List all the installed Packages

To view and list all the installed packages, use the “-l” option along with the command.

[root@tecmint~]# dpkg -l
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                   Version                  Architecture    Description
+++-======================================-========================-===============================================================================
ii  accerciser                             3.8.0-0ubuntu1           all             interactive Python accessibility explorer for the GNOME desktop
ii  account-plugin-aim                     3.6.4-0ubuntu4.1         i386            Messaging account plugin for AIM
ii  account-plugin-facebook                0.10bzr13.03.26-0ubuntu1 i386            GNOME Control Center account plugin for single signon - facebook
ii  account-plugin-flickr                  0.10bzr13.03.26-0ubuntu1 i386            GNOME Control Center account plugin for single signon - flickr
ii  account-plugin-generic-oauth           0.10bzr13.03.26-0ubuntu1 i386            GNOME Control Center account plugin for single signon - generic OAuth
ii  account-plugin-google                  0.10bzr13.03.26-0ubuntu1 i386            GNOME Control Center account plugin for single signon
rc  account-plugin-identica                0.10bzr13.03.26-0ubuntu1 i386            GNOME Control Center account plugin for single signon - identica
ii  account-plugin-jabber                  3.6.4-0ubuntu4.1         i386            Messaging account plugin for Jabber/XMPP
....

To view a specific package installed or not use the option “-l” along with package-name. For example, check whether apache2 package installed or not.

[root@tecmint~]# dpkg -l apache2
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                   Version                  Architecture    Description
+++-======================================-========================-==============================================
ii  apache2                                2.2.22-6ubuntu5.1        i386            Apache HTTP Server metapackage

3. Remove a Package

To remove the “.deb” package, we must specify the package name “flashpluginnonfree“, not the original name “flashplugin-nonfree_3.2_i386.deb“. The “-r” option is used to remove/uninstall a package.

[root@tecmint~]# dpkg -r flashpluginnonfree
(Reading database ... 142891 files and directories currently installed.) 
Removing flashpluginnonfree ... 
Processing triggers for man-db ... 
Processing triggers for menu ... 
Processing triggers for desktop-file-utils ... 
Processing triggers for gnome-menus ...

You can also use ‘p‘ option in place of ‘r’ which will remove the package along with configuration file. The ‘r‘ option will only remove the package and not configuration files.

[root@tecmint~]# dpkg -P flashpluginnonfree

4. View the Content of a Package

To view the content of a particular package, use the “-c” option as shown. The command will display the contents of a “.deb” package in long-list format.

[root@tecmint~]# dpkg -c flashplugin-nonfree_3.2_i386.deb
drwxr-xr-x root/root         0 2012-12-14 22:54 ./
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/bin/
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/lib/
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/lib/mozilla/
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/lib/mozilla/plugins/
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/lib/flashplugin-nonfree/
-rw-r--r-- root/root      3920 2009-09-09 22:51 ./usr/lib/flashplugin-nonfree/pubkey.asc
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/share/
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/share/man/
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/share/man/man8/
-rw-r--r-- root/root       716 2012-12-14 22:54 ./usr/share/man/man8/update-flashplugin-nonfree.8.gz
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/share/applications/
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/share/icons/
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/share/icons/hicolor/
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/share/icons/hicolor/24x24/
....

5. Check a Package is installed or not

Using “-s” option with package name, will display whether an deb package installed or not.

[root@tecmint~]# dpkg -s flashplugin-nonfree
Package: flashplugin-nonfree
Status: install ok installed
Priority: optional
Section: contrib/web
Installed-Size: 177
Maintainer: Bart Martens <bartm@debian.org>
Architecture: i386
Version: 1:3.2
Replaces: flashplugin (<< 6) Depends: debconf | debconf-2.0, wget, gnupg, libatk1.0-0, libcairo2, libfontconfig1, libfreetype6, libgcc1, libglib2.0-0, libgtk2.0-0 (>= 2.14), libnspr4, libnss3, libpango1.0-0, libstdc++6, libx11-6, libxext6, libxt6, libcurl3-gnutls, binutils
Suggests: iceweasel, konqueror-nsplugins, ttf-mscorefonts-installer, ttf-dejavu, ttf-xfree86-nonfree, flashplugin-nonfree-extrasound, hal
Conflicts: flashplayer-mozilla, flashplugin (<< 6), libflash-mozplugin, xfs (<< 1:1.0.1-5)
Description: Adobe Flash Player - browser plugin
...

6. Check the location of Packages installed

To list location of files to be installed to your system from package-name.

[root@tecmint~]# dpkg -L flashplugin-nonfree
/.
/usr
/usr/bin
/usr/lib
/usr/lib/mozilla
/usr/lib/mozilla/plugins
/usr/lib/flashplugin-nonfree
/usr/lib/flashplugin-nonfree/pubkey.asc
/usr/share
/usr/share/man
/usr/share/man/man8
/usr/share/man/man8/update-flashplugin-nonfree.8.gz
/usr/share/applications
/usr/share/icons
/usr/share/icons/hicolor
...

7. Install all Packages from a Directory

Recursively, install all the regular files matching pattern “*.deb” found at specified directories and all of its subdirectories. This can be used with “-R” and “–install” options. For example, I will install all the “.deb” packages from the directory called “debpackages“.

[root@tecmint~]# dpkg -R --install debpackages/
(Reading database ... 465836 files and directories currently installed.)
Preparing to replace flashplugin-nonfree 1:3.2 (using .../flashplugin-nonfree_3.2_i386.deb) ...
Unpacking replacement flashplugin-nonfree ...
Setting up flashplugin-nonfree (1:3.2) ...
Processing triggers for man-db ...
Processing triggers for bamfdaemon ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for gnome-menus ...

8. Unpack the Package but dont’ Configure

Using action “–unpack” will unpack the package, but it will don’t install or configure it.

[root@tecmint~]# dpkg --unpack flashplugin-nonfree_3.2_i386.deb
(Reading database ... 465836 files and directories currently installed.)
Preparing to replace flashplugin-nonfree 1:3.2 (using flashplugin-nonfree_3.2_i386.deb) ...
Unpacking replacement flashplugin-nonfree ...
Processing triggers for man-db ...
Processing triggers for bamfdaemon ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for gnome-menus ...

9. Reconfigure a Unpacked Package

The option “–configure” will reconfigure a already unpacked package.

[root@tecmint~]# dpkg --configure flashplugin-nonfree
Setting up flashplugin-nonfree (1:3.2) ...

10. Replace available Package information

The “–-update-avail” option replace the old information with the available information in the Packages file.

[root@tecmint~]# dpkg –-update-avail package_name

11. Erase Existing Available information of Package

The action “–clear-avaial” will erase the current information about what packages are available.

[root@tecmint~]# dpkg –-clear-avail

12. Forget Uninstalled and Unavailable Packages

The dpkg command with option “–forget-old-unavail” will automatically forget uninstalled and unavailable packages .

[root@tecmint~]# dpkg --forget-old-unavail

13. Display dpkg Licence

[root@tecmint~]# dpkg --licence

14. Display dpkg Version

The “–version” argument will display dpkg version information.

[root@tecmint~]# dpkg –version
Debian `dpkg' package management program version 1.16.10 (i386).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.

15. Get all the Help about dpkg

The “–help” option will display a list of available options of dpkg command.

[root@tecmint~]# dpkg –help
Usage: dpkg [ ...] 

Commands:
  -i|--install        ... | -R|--recursive  ...
  --unpack            ... | -R|--recursive  ...
  -A|--record-avail   ... | -R|--recursive  ...
  --configure         ... | -a|--pending
  --triggers-only     ... | -a|--pending
  -r|--remove         ... | -a|--pending
  -P|--purge          ... | -a|--pending
  --get-selections [ ...] Get list of selections to stdout.
  --set-selections                 Set package selections from stdin.
  --clear-selections               Deselect every non-essential package.
  --update-avail    Replace available packages info.
  --merge-avail     Merge with info from file.
  --clear-avail                    Erase existing available info.
  --forget-old-unavail             Forget uninstalled unavailable pkgs.
  -s|--status  ...        Display package status details.
...

That’s all for now. I’ll soon be here again with another interesting article. If I’ve missed any command in the list do let me know via comments. Till then, Stay tuned and Keep connected to Tecmint. Like and share us and help us spread. Don’t forget to mention your valuable thoughts in comment.

——

many and many and many times I see sudo dpkg-reconfigure postfix what is that?

Packages (like postfix) may install or generate configuration files (files that usually go in the /etcfolder). During this process, there may be options that can be changed by the user. On installation, you are usually asked to set these options. In the case of postfix, it involves what type of server you’re running, the hostname, and allowed IP addresses (among other things).

If you wanted to change those options afterwards, though, you can use dpkg-reconfigure which only goes through the configuration files phase of the package, where you can change those options.

Note that not all packages have user-configurable options, so even if a package installs a configuration file in /etc, dpkg-reconfigure might not do anything.

Advertisements

Posted on June 16, 2015, in Linux (Ubuntu/CentOS). Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: