Our sixty-fourth word, or command to memorize is
dpkg from our category
dpkg allows you to manage software
Common Linux dpkg Options
Print help screen
List installed packages
Display status of a package
Recall from video 14, we used
whereis to locate programs, and here
we'll start a general discussion about how software packages are
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
-l option lists, and
-s provides the status of installed
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
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.
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
$ dpkg --help
Usage: dpkg [<option> ...] <command>
-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.
--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.
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 dependencies involving <package>.
--force-... Override problems (see --force-help).
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.
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
Wow, there's a lot in there, right? And for homework, open it in
less and see what you have on your
And last, let's try that -s option
for the status on the program less.
$ dpkg -s less
Status: install ok installed
Maintainer: Anibal Monsalve Salazar <firstname.lastname@example.org>
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.
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: