FactorPad
Faster Learning Tutorials

Linux dpkg command summary with examples

dpkg allows you to manage software packages.
  1. Purpose - Learn what dpkg is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with dpkg.
  4. A tip - Finish off with one more insight.
Paul Alan Davis, CFA, November 3, 2016
Updated: July 25, 2018
In this tutorial, 64 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Next

~/ home  / tech  / linux essentials  / dpkg command


The Linux dpkg command

Beginner

Learn to manage software applcations at the Linux command line.

Video Tutorial

Linux dpkg command summary with examples (3:36)

Videos can also be accessed from the YouTube Playlist.

Video Script

The Command and Why You Need It

Our sixty-fourth word, or command to memorize is dpkg from our category System.

dpkg allows you to manage software packages.

Recall from video 14, we used whereis to locate programs, and here we'll start a general discussion about how software packages are installed.

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The dpkg command has over 30 options and the argument can be an action on a software package name or package file.

Like most commands, help is available with double-dash --help. The -l option lists, and -s provides the status of installed packages.

We'll keep it basic as these tasks are often left to administrators. Please note, separate commands apply to two types of Linux distributions, Debian-style is dpkg, mine here, and Fedora-style is rpm.

So why is dpkg an important command? Well, for most of us, what comes out of the box isn't enough, so we'll need a way to install software. And now you know how to do that.

Demonstration

Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go. Start by quickly printing a help screen, and this will illustrate why package management is so complex, and please review this later.

$ dpkg --help Usage: dpkg [<option> ...] <command> Commands: -i|--install <.deb file name> ... | -R|--recursive <directory> ... --unpack <.deb file name> ... | -R|--recursive <directory> ... -A|--record-avail <.deb file name> ... | -R|--recursive <directory> ... --configure <package> ... | -a|--pending --triggers-only <package> ... | -a|--pending -r|--remove <package> ... | -a|--pending -P|--purge <package> ... | -a|--pending -V|--verify <package> ... Verify the integrity of package(s). --get-selections [<pattern> ...] Get list of selections to stdout. --set-selections Set package selections from stdin. --clear-selections Deselect every non-essential package. --update-avail [<Packages-file>] Replace available packages info. --merge-avail [<Packages-file>] Merge with info from file. --clear-avail Erase existing available info. --forget-old-unavail Forget uninstalled unavailable pkgs. -s|--status <package> ... Display package status details. -p|--print-avail <package> ... Display available version details. -L|--listfiles <package> ... List files `owned' by package(s). -l|--list [<pattern> ...] List packages concisely. -S|--search <pattern> ... Find package(s) owning file(s). -C|--audit [<package> ...] Check for broken package(s). --add-architecture <arch> Add <arch> to the list of architectures. --remove-architecture <arch> Remove <arch> from the list of architectures. --print-architecture Print dpkg architecture. --print-foreign-architectures Print allowed foreign architectures. --compare-versions <a> <op> <b> Compare version numbers - see below. --force-help Show help on forcing. -Dh|--debug=help Show help on debugging. -?, --help Show this help message. --version Show the version. Use dpkg -b|--build|-c|--contents|-e|--control|-I|--info|-f|--field| -x|--extract|-X|--vextract|--fsys-tarfile on archives (type dpkg-deb --help). For internal use: dpkg --assert-support-predepends | --predep-package | --assert-working-epoch | --assert-long-filenames | --assert-multi-conrep | --assert-multi-arch | --assert-versioned-provides. Options: --admindir=<directory> Use <directory> instead of /var/lib/dpkg. --root=<directory> Install on a different root directory. --instdir=<directory> Change installation dir without changing admin dir. --path-exclude=<pattern> Do not install paths which match a shell pattern. --path-include=<pattern> Re-include a pattern after a previous exclusion. -O|--selected-only Skip packages not selected for install/upgrade. -E|--skip-same-version Skip packages whose same version is installed. -G|--refuse-downgrade Skip packages with earlier version than installed. -B|--auto-deconfigure Install even if it would break some other package. --[no-]triggers Skip or force consequential trigger processing. --verify-format=<format> Verify output format (supported: 'rpm'). --no-debsig Do not try to verify package signatures. --no-act|--dry-run|--simulate Just say what we would do - don't do it. -D|--debug=<octal> Enable debugging (see -Dhelp or --debug=help). --status-fd <n> Send status change updates to file descriptor <n>. --status-logger=<command> Send status change updates to <command>'s stdin. --log=<filename> Log status changes and actions to <filename>. --ignore-depends=<package>,... Ignore dependencies involving <package>. --force-... Override problems (see --force-help). --no-force-...|--refuse-... Stop when problems encountered. --abort-after <n> Abort after encountering <n> errors. Comparison operators for --compare-versions are: lt le eq ne ge gt (treat empty version as earlier than any version); lt-nl le-nl ge-nl gt-nl (treat empty version as later than any version); < << <= = >= >> > (only for compatibility with control file syntax). Use 'apt' or 'aptitude' for user-friendly package management. $ clear

Now let's redirect the dpkg -l package listing to a file called video64.txt, and this shows what you have on your system.

Let's do a wc -l to the count lines.

$ wc -l video64.txt 442 video64.txt

Wow, there's a lot in there, right? And for homework, open it in less and see what you have on your system.

And last, let's try that -s option for the status on the program less.

$ dpkg -s less Package: less Status: install ok installed Priority: important Section: text Installed-Size: 253 Maintainer: Anibal Monsalve Salazar <anibal@debian.org> Architecture: amd64 Multi-Arch: foreign Version: 458-3 Depends: libc6 (>= 2.14), libtinfo5, debianutils (>= 1.8) Description: pager program similar to more This package provides "less", a file pager (that is, a memory-efficient utility for displaying text one screenful at a time). Less has many more features than the basic pager "more". As part of the GNU project, it is widely regarded as the standard pager on UNIX-derived systems. . Also provided are "lessecho", a simple utility for ensuring arguments with spaces are correctly quoted; "lesskey", a tool for modifying the standard (vi-like) keybindings; and "lesspipe", a filter for specific types of input, such as .doc or .txt.gz files. Homepage: http://www.greenwoodsoftware.com/less/

It reports: status, size, maintainer, version and dependencies.

A Final Tip

Okay now you know how to use dpkg. And you know the syntax for commands, options and arguments.

One last tip about the dpkg command. So the focus of dpkg is on downloaded files, next we'll talk about accessing repositories.

Okay, thanks for visiting today. I hope this was a helpful introduction to the dpkg command.


Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:


What's Next?

If you found value here and would like to keep learning, please consider subscribing to our YouTube Channel.

  • For the Outline to all 100 tutorials, click Outline.
  • To go back to the jobs command, hit Back.
  • To stick with high-level summaries of package management programs with apt-get, click Next.

Outline Back Next

~/ home  / tech  / linux essentials  / dpkg command



 
 
Keywords:
linux dpkg command
dpkg Linux
dpkg list
dpkg install
list installed packages in Linux
man dpkg
sudo dpkg
manage packages
deb files
dpkg status
dpkg list
debian package files
linux package status
downloaded package files in linux
linux software packages
linux download software
linux dependencies