Study guide

13.1 dpkg Fundamentals

Kali Linux Certified Professional KLCP

Track your progress as you read

Finished sections get a check mark.

1 Introduction & Exam Overview

1.1 Current Exam Facts 1.2 How to Use This Guide & Study Strategy 1.3 PEN-103 Syllabus & Study Path

2 About Kali Linux

2.1 A Bit of History: From BackTrack to Kali 2.2 Kali's Relationship with Debian 2.3 Purpose and Use Cases 2.4 Main Features and Design Policies

3 Getting Started with Kali Linux

3.1 Downloading and Verifying a Kali ISO 3.2 Booting Kali in Live Mode 3.3 Installation Options Overview 3.4 Troubleshooting Installations

4 Linux Fundamentals

4.1 What Linux Is and What It Does 4.2 The Command Line 4.3 The Filesystem Hierarchy Standard 4.4 Useful Commands: Files, Search, Environment

5 Permissions and Process Management

5.1 File Permissions and Ownership 5.2 Managing Processes 5.3 Shells, Variables, and the Environment

6 Installing Kali Linux

6.1 Minimal Installation Requirements 6.2 Step-by-Step Installation on a Hard Drive 6.3 Unattended Installations with Preseeding 6.4 ARM Installations

7 Configuring the Network, Users, and SSH

7.1 Configuring the Network 7.2 Managing Unix Users and Groups 7.3 Configuring SSH

8 Configuring Services

8.1 Apache Web Server 8.2 PostgreSQL Database 8.3 Managing Services with systemd

9 Helping Yourself and Getting Help

9.1 Documentation Sources 9.2 Kali Linux Communities 9.3 Filing Good Bug Reports

10 Security Policy and Network Services

10.1 Defining a Security Policy 10.2 Possible Security Measures 10.3 Securing Network Services

11 Firewalling and Monitoring

11.1 Netfilter and iptables Behavior 11.2 Writing iptables Rules and NAT 11.3 Monitoring and Logging

12 Debian Package Management: APT

12.1 Introduction to APT 12.2 The sources.list File 12.3 Kali Repositories 12.4 Basic Package Interaction with apt

13 dpkg and Advanced Package Management

13.1 dpkg Fundamentals 13.2 Inspecting .deb Files and Package State 13.3 Maintainer Scripts and Conffiles 13.4 APT Pinning and Package Authenticity

14 Advanced Usage

14.1 Modifying and Rebuilding Kali Packages 14.2 Recompiling the Kernel 14.3 Building Custom Kali Live ISO Images 14.4 USB Persistence with LUKS Encryption

15 Kali Linux in the Enterprise

15.1 Network Installation with PXE Boot 15.2 Configuration Management with SaltStack 15.3 Metapackages and Custom Repositories 15.4 Configuration Packages and Forking

16 Introduction to Security Assessments

16.1 Kali Linux in an Assessment 16.2 Types of Assessments 16.3 Types of Attacks 16.4 Formalization and the Road Ahead

13.1 dpkg Fundamentals

Key Takeaways Explain This Topic AI

dpkg is the low-level Debian package tool: it installs and removes individual .deb files but performs no dependency resolution or repository downloads

dpkg -i installs a local .deb file; dpkg -r removes a package but leaves its conffiles, while dpkg -P (purge) removes the package and its conffiles

The first two columns of dpkg -l output encode desired state and current status: ii means installed, rc means removed with conffiles remaining, un means never installed

dpkg --configure -a re-runs configuration for every unpacked-but-unconfigured package and is the standard recovery step after an interrupted install

APT is a front-end layered on top of dpkg: apt fetches packages from repositories and resolves dependencies, then hands the actual installation work to dpkg

Last updated: July 2026

What dpkg Actually Does

dpkg is the low-level package manager at the heart of every Debian-based system, including Kali Linux. Every package you install — whether you typed apt install nmap or dpkg -i something.deb — ultimately passes through dpkg, because dpkg is the tool that unpacks archives, runs maintainer scripts, and records package state in its database at /var/lib/dpkg/ . APT (Advanced Package Tool) is a higher-level front-end layered on top of dpkg: it downloads packages from repositories like kali-rolling , resolves dependency chains, verifies signatures, and then invokes dpkg to perform the actual installation.

This division of labor is a favorite exam topic. The rule is simple: dpkg works only on files that already exist on your disk and knows nothing about dependencies or repositories. If a package needs libraries that are not installed, dpkg will fail and leave the package half-configured; apt would have fetched those libraries automatically.

Installing a Local Package: dpkg -i

Use dpkg -i (or the long form dpkg --install ) to install a .deb file you have already downloaded: $ sudo dpkg -i /home/kali/Downloads/mypackage_1.2.3_amd64.deb

Selecting previously unselected package mypackage.

(Reading database ... 312450 files and directories currently installed.)

Preparing to unpack .../mypackage_1.2.3_amd64.deb ...

Unpacking mypackage (1.2.3) ...

Setting up mypackage (1.2.3) ...

You can pass several .deb files in one command, or use dpkg -iR /path/to/dir/ ( --recursive ) to install every package found under a directory tree. The danger appears when dependencies are missing: dpkg: dependency problems prevent configuration of mypackage:

mypackage depends on libfoo2 (>= 2.0); however:

Package libfoo2 is not installed.

dpkg still unpacks the package but leaves it unconfigured (an iU state). The classic fix is sudo apt -f install ( --fix-broken ), which asks apt to fetch the missing dependencies from the configured repositories and finish the job dpkg could not. Remember: dpkg itself will never go to the network to solve this for you.

Removing vs Purging: dpkg -r and dpkg -P

Two commands remove packages, and the difference matters on the exam:

dpkg -r package ( --remove ) deletes the package's files but keeps its conffiles — the configuration files under /etc that dpkg tracks specially. This is deliberate: if you reinstall later, your settings are still there.

dpkg -P package ( --purge ) removes the package including its conffiles , leaving no dpkg-tracked trace behind.

Note that even a purge does not touch files created at runtime — log files in /var/log , data in /var/lib , or per-user dotfiles in home directories are the administrator's problem, not dpkg's.

Reading dpkg -l and the Status Flags

dpkg -l lists every package dpkg knows about. Each line begins with a status code whose first two letters you must be able to decode:

  • Code First letter (desired state) Second letter (current status) Meaning
  • ii i = install i = installed Package is installed and configured — the normal state
  • rc r = remove c = config-files Removed, but conffiles remain on disk
  • un u = unknown n = not-installed Package was never installed
  • iU i = install U = unpacked Unpacked but not configured (interrupted or missing deps)
  • iF i = install F = half-configured Configuration failed partway through

The first column is the desired state (what you asked for: u unknown, i install, r remove, p purge, h hold), the second is the current status ( n not-installed, i installed, c config-files only, U unpacked, F half-configured, H half-installed, W triggers-awaited, t triggers-pending — dpkg prints the "bad" states in uppercase), and a possible third column flags an error ( R means reinstallation required). A classic trap: rc does not mean "running config" or "recently changed" — it means the package was removed and only its configuration files survive. You can filter on this directly, for example dpkg -l | grep '^rc' to find leftover conffiles you might want to purge.

dpkg --get-selections is a related query: it prints just the package name and desired state ( install , deinstall , purge , hold ), and piping it back into dpkg --set-selections is how administrators clone a package set onto another machine.

Recovering from an Interrupted Install

If an install is cut short — a Ctrl-C at the wrong moment, a dead SSH session, a power failure — packages can be left unpacked but unconfigured. The recovery command is: $ sudo dpkg --configure -a

The -a (or --pending ) flag tells dpkg to configure every package that is unpacked but not yet configured . You will also see apt suggest this exact command when its own operations detect a broken state. Do not confuse this with dpkg-reconfigure package , which is a debconf helper that re-asks a package's configuration questions — a different tool for a different problem.

dpkg vs apt: Scope and Responsibility

  • Capability dpkg apt
  • Install local .deb files Yes Yes ( apt install ./file.deb )
  • Download from repositories No Yes
  • Dependency resolution No (reports problems only) Yes, automatic
  • Signature/repository verification No Yes
  • Unpacks files, runs maintainer scripts Yes Delegates to dpkg
  • Tracks the package database Yes ( /var/lib/dpkg ) Uses dpkg's database

The mental model to carry into the exam: apt decides what to install and fetches it; dpkg physically installs it. When a question asks which tool "cannot resolve dependencies" or "operates only on local .deb files," the answer is dpkg. When a question asks which tool talks to kali-rolling , the answer is apt.

Two final operational flags round out the fundamentals. To stop apt from upgrading a package, put it on hold : echo "nmap hold" | sudo dpkg --set-selections (or sudo apt-mark hold nmap ) flips its desired state to h , and dpkg -l then shows hi . And dpkg --audit ( -C ) lists packages that are only partly installed or otherwise need attention — a quick health check of the dpkg database before a big upgrade.