Package managementBeginner24 min read

What Does dpkg Mean?

Reviewed byJohnson Ajibi· Senior Network & Security Engineer · MSc IT Security

This page mentions older exam versions. See the Current Exam Context and Legacy Exam Context sections below for the updated mapping.

On This Page

Quick Definition

dpkg is a low-level tool that helps you install, remove, and get information about software packages on Debian-based Linux systems like Ubuntu. It works directly with .deb package files but does not automatically handle dependencies or download packages from the internet. Think of it as the basic installer that handles one package at a time, while tools like APT are smarter and manage dependencies for you.

Common Commands & Configuration

dpkg -i package.deb

Install a .deb package file. This unpacks the archive and runs configuration scripts.

dpkg -r packagename

Remove an installed package but keep its configuration files. Use -P to purge completely.

dpkg -l

List all installed packages matching a pattern. Use dpkg -l | less to paginate.

dpkg -L packagename

List all files installed by a specific package. Useful for finding configuration files.

Must Know for Exams

dpkg appears prominently in several IT certification exams, most notably CompTIA Linux+ (XK0-005) and LPIC-1 (101-500). For CompTIA Linux+, the exam objectives under the Software Configuration and Management domain explicitly require candidates to install, uninstall, and reinstall software packages using Debian package management tools. This means you need to know dpkg commands such as -i for install, -r for remove, -P for purge, -l for list, -s for status, and -L for listing files.

The exam often includes scenario-based questions where you must choose the correct command to accomplish a task. For example, a question might state: A user downloaded a package file named app_v2.deb.

Which command should be used to install it? The correct answer is dpkg -i app_v2.deb. Another common question type asks you to identify the command that shows all files installed by a particular package, and the answer is dpkg -L packagename.

For LPIC-1, topic 102.4 covers Debian package management in depth. Candidates are expected to know dpkg, APT, and other related tools. The exam may ask you to explain the difference between dpkg and APT, or to use dpkg to query the system.

The exam could present a troubleshooting scenario where APT is failing due to a corrupted database, and you need to use dpkg to fix the issue. Scenario-based questions might describe a situation where a package installation fails because of unmet dependencies, and you must know that dpkg will report the error but not resolve it. You might also be asked how to override that behavior, though it is generally discouraged.

The Red Hat Certified System Administrator (RHCSA) exam focuses on RPM-based systems, so dpkg is not directly tested, but understanding package management concepts is transferable. For Ubuntu Certified Professional, dpkg is a primary topic. Exam questions about dpkg are typically command recall and scenario-based.

You will rarely see multiple-step troubleshooting without clear clues. The best preparation is to practice dpkg commands in a live environment. Create a virtual machine with Ubuntu, download a .

deb package like a small application, and practice installing, removing, and querying it. Also, practice using the dpkg --get-selections command to dump the list of installed packages, and dpkg --purge to remove configuration files. Knowing these commands cold will serve you well on exam day.

Simple Meaning

Imagine you are building a model car from a kit. The kit comes in a box with instructions, wheels, body parts, and a motor. dpkg is like a tool that can open that box and put the parts into the right places in your room.

But here is the catch: dpkg only knows how to install one box at a time. If your model car needs wheels from a different kit, dpkg will complain and tell you that the wheels are missing. It will not go get them for you.

That is why most people use a smarter tool like APT, which is like a helper that not only installs your box but also goes to the store to fetch any missing parts you need. dpkg is still very useful when you already have the right box in your hand and you just want to put it together. For example, if you download a software package directly from a website as a .

deb file, you would use dpkg to install it. dpkg also lets you see what packages are installed on your system, check their version numbers, and remove them if you no longer need them. Software packages on Linux are like collections of files that need to be placed in specific directories.

dpkg knows exactly where each file should go, so it can set up the software correctly. It also keeps a database of every package it has installed, so it can tell you what you have and help you clean up. dpkg is a fundamental tool for anyone who manages Linux servers or desktops, especially in exam contexts for certifications like CompTIA Linux+ or LPIC.

It works behind the scenes even when you use more advanced tools, because those tools simply call dpkg to do the actual installation work. Understanding dpkg gives you a solid foundation for Linux package management.

Full Technical Definition

dpkg is the Debian Package Manager, a low-level tool for installing, removing, and querying software packages in the Debian package management ecosystem. It operates directly on .deb archive files, which are compressed archives containing the software binaries, configuration files, metadata, and installation scripts.

The dpkg command interacts with the dpkg database, located in /var/lib/dpkg/, which maintains a record of all installed packages, their versions, statuses, and file manifests. When you run dpkg -i package.deb, it performs several steps: it extracts the archive contents, runs pre-installation scripts if present, copies files to their designated locations according to the filesystem hierarchy standard, updates the dpkg database, and runs post-installation scripts.

The tool uses a state machine to track each package through statuses such as unpacked, half-configured, installed, and removed. dpkg supports a variety of options including -l to list packages matching a pattern, -L to list files owned by a package, -s to show package status, and -S to search for which package owns a specific file. Unlike APT, dpkg does not resolve dependencies automatically.

If a package requires another package that is not installed, dpkg will report a dependency error and refuse to install unless you use the --force-depends option, which is risky and can break your system. dpkg also supports reconfigure mode via dpkg-reconfigure, which allows you to reconfigure an already installed package by running its configuration scripts again. In real IT implementation, system administrators use dpkg primarily when working offline, when installing custom or locally built packages, or when troubleshooting APT issues.

dpkg is also essential during system recovery scenarios where APT may be broken but dpkg is still functional. It is a core component of the Debian package system and is called internally by higher-level tools like APT, aptitude, and synaptic. Understanding dpkg is critical for the CompTIA Linux+ exam (XK0-005) under the package management domain, and for the LPIC-1 exam (101-500) under topic 102.

4, which covers using Debian package management. The tool adheres to the Debian Free Software Guidelines and uses the .deb format, which includes control files with metadata like the package name, version, architecture, dependencies, maintainer, and description.

dpkg can also be used to extract the contents of a .deb file without installing it, which is useful for inspecting or repackaging software.

Real-Life Example

Think of your smartphone and the app store. Normally, you open the app store, search for a game, and tap Install. The app store automatically downloads the game, installs it, and also downloads any other required pieces like a graphics library or a login system.

That is like using APT. Now imagine you are at a friend's house and they give you a game file on a USB drive. You take that file and want to put it on your phone. You cannot use the app store because the file is not from the store.

Instead, you have to manually copy the file to your phone and run an installer that just puts that one game in place. If the game needs a login library that your phone does not have, the installer will say, Sorry, missing login library. It will not go download it for you.

That installer is like dpkg. You have the package right there in your hand, but you must deal with missing pieces yourself. In the real world, companies often need to install custom software on many servers.

They might download the .deb files to a local server and then use dpkg to install them on machines that do not have internet access. This keeps the environment secure and controlled.

Another everyday example is when you buy a new piece of furniture from a store that comes in a box with all the pieces. You bring it home and assemble it yourself. dpkg is like your screwdriver and instructions that tell you exactly where each piece goes.

But if you find that a screw is missing, dpkg will stop and tell you it is missing. It will not run to the hardware store for you. That is why you keep a box of spare screws (like having dependencies already installed) or use APT to fetch them.

The analogy helps you see that dpkg is powerful for direct installation but limited when things are not pre-arranged.

Why This Term Matters

dpkg matters because it is the bedrock of package management on Debian and Ubuntu systems, which power a huge percentage of web servers, cloud instances, and enterprise Linux environments. When you manage servers for a living, you will frequently encounter situations where APT is broken or unavailable due to network issues, repository problems, or system corruption. In those moments, dpkg is your lifeline.

It allows you to manually install, remove, or reinstall packages even when the higher-level tools are failing. Knowing dpkg gives you the ability to repair a system from the ground up. For example, if a critical security update fails because of a dependency conflict, you can use dpkg to force install a specific package version and then fix the conflict manually.

dpkg also lets you inspect packages in detail. You can find out which package owns a configuration file, check the version of an installed package, or list all files a package placed on your system. This is invaluable for auditing, compliance, and troubleshooting.

Without dpkg, you would be flying blind when something goes wrong with APT. Dpkg is a fundamental concept in Linux certification exams. CompTIA Linux+ and LPIC-1 both test your ability to use dpkg commands to manage packages.

A typical exam question might ask you to install a .deb file you downloaded, or to find which package provides a specific command. If you only know how to use APT, you will miss those points.

Becoming comfortable with dpkg also helps you understand how package management works at a deeper level. It demystifies the process of software installation and makes you a more confident system administrator. In short, dpkg is not just a tool; it is a core survival skill for Linux professionals.

How It Appears in Exam Questions

dpkg questions in certification exams generally fall into three categories: command recall, scenario-based troubleshooting, and conceptual comparison. In command recall questions, you are given a specific task and must pick the correct dpkg option. For example, Which command displays the status of a package named curl?

The answer is dpkg -s curl. Another example: A technician needs to remove a package named oldapp but keep its configuration files. Which command should they use? The answer is dpkg -r oldapp.

To completely remove the package and its configuration, it is dpkg -P oldapp. Scenario-based troubleshooting questions often present a broken system. For instance, An administrator tries to install a package using APT but receives an error about a corrupted package database.

What command can be used to reconfigure the database? The answer is to use dpkg --configure -a, which attempts to configure any packages that were left in an unpacked or half-configured state. Another scenario: A user downloaded a .

deb file but when they try to install it with dpkg, they get a dependency error. The question might ask what this error indicates and how to resolve it properly. The correct approach is to use APT to install the missing dependencies first, then use dpkg to install the .

deb file. Some questions test your understanding of dpkg limitations. For example, Which of the following is a limitation of dpkg compared to APT? The answer is that dpkg does not automatically resolve dependencies.

Another conceptual question might ask you to identify the file that dpkg uses to track installed packages. The answer is /var/lib/dpkg/status. You might also see questions that require you to interpret dpkg output.

For example, after running dpkg -l | grep ssh, you might see a status line like ii openssh-client 8.9p1-3 ubuntu. The question might ask what the ii means, and you need to know that the first i indicates the package is desired to be installed and the second i indicates it is actually installed.

Other letters include r for remove and p for purge. In advanced scenarios, you may be asked to fix a broken system where a package is half-installed. The correct recovery command is dpkg --configure -a, or in extreme cases, dpkg --remove --force-depends packagename.

Finally, exam questions may ask you to compare dpkg with RPM, the equivalent tool on Red Hat systems. For example, What is the equivalent of dpkg -i on RPM-based systems? The answer is rpm -ivh.

Knowing these parallels can help you in cross-platform questions. To prepare, practice with a virtual machine and simulate these scenarios. The more hands-on experience you have, the easier these questions will be.

Study CompTIA Linux+

Test your understanding with exam-style practice questions.

Practise

Example Scenario

You are a junior system administrator for a small company that uses Ubuntu servers for its web applications. Your boss hands you a USB drive containing a custom .deb package called company-tool-2.

4.deb. This package contains an internal monitoring tool that was built by the development team. The server you need to install it on does not have internet access because it is in a secure network zone.

You insert the USB drive and copy the file to your home directory. Now you must install it. You remember from your certification studies that dpkg is the right tool for installing a .

deb file directly. You open a terminal and type sudo dpkg -i company-tool-2.4.deb. The command runs, but you see an error message: dpkg: dependency problems prevent configuration of company-tool.

The tool requires a library called libhelper2 that is not installed on the server. You cannot use APT because there is no internet, but you check the USB drive and find that the development team also provided a dependencies folder containing libhelper2.deb.

You install that first using sudo dpkg -i libhelper2.deb. It installs successfully. Then you rerun sudo dpkg -i company-tool-2.4.deb, and this time it completes without errors. You verify the installation by running dpkg -l | grep company-tool, which shows the package is installed.

You also check which files were installed using dpkg -L company-tool, confirming that the binary and configuration files are in place. Later, your boss asks you to remove an old version of the monitoring tool, version 2.3, from another server.

You use sudo dpkg -r company-tool to remove the package, keeping the configuration files in case they are needed. But your boss then says to completely remove everything, including configuration. You use sudo dpkg -P company-tool to purge it.

This scenario teaches you that dpkg is essential for offline installations and that you must be prepared to handle dependencies manually. It also shows that dpkg commands are simple but powerful when used correctly.

Common Mistakes

Using dpkg -i on a .deb file that has unmet dependencies and ignoring the error, thinking the package is installed

dpkg will report a dependency error and leave the package in an unpacked but unconfigured state. The package is not fully installed and may not function correctly. Continuing without resolving dependencies can lead to a broken system.

Always resolve the missing dependencies first. Use apt-get install -f to automatically fix dependencies after a failed dpkg install, or manually install the required packages before retrying dpkg -i.

Using dpkg -r to remove a package and thinking it removes all traces, including configuration files

dpkg -r removes the package but leaves behind configuration files in /etc. The package is marked with status deinstall ok config-files. This is often not what administrators intend when they want a clean removal.

Use dpkg -P (purge) to remove the package and all its configuration files. Check the package status with dpkg -s packagename to see if it still has config files left.

Confusing dpkg -l output and misinterpreting the status flags

The first letter shows the desired action (install, remove, purge) and the second shows the actual current state. For example, 'ii' means installed, but 'ri' means the package is marked for removal but still installed. Beginners often misread these flags and think a package is properly installed when it is actually in a transitional state.

Always check both letters. The status field is documented in the dpkg man page. Use dpkg -s for a detailed status of a single package if you are unsure. Practice reading the output on a test system.

Using dpkg --force-depends as a quick fix for dependency errors

This flag forces dpkg to install the package even if dependencies are missing. It can leave the system in an inconsistent state where software depends on libraries that are not present, leading to crashes or security vulnerabilities. This is a dangerous practice in production environments.

Only use --force-depends as a last resort during system recovery when you know exactly what you are doing. The proper fix is to install the missing dependencies. Use apt-get install -f to automatically correct broken dependencies.

Exam Trap — Don't Get Fooled

{"trap":"An exam question presents a scenario where a package fails to install due to a missing dependency, and asks you which command to use next. One answer option is dpkg --force-depends -i package.deb, and another is apt-get install -f.

Learners often pick the force option because it seems like a direct fix.","why_learners_choose_it":"Learners see the word 'force' and think it will make the installation work immediately. They may not realize that forcing dependencies is a brute-force approach that can break the system.

They also may not know about apt-get install -f, which is the intended way to fix dependency problems automatically.","how_to_avoid_it":"Always think about the best practice for dependency resolution. The correct and safe approach is to use apt-get install -f after a failed dpkg install.

This command will scan the system for missing dependencies and install them from the repositories. Only consider --force-depends if you are explicitly told in the scenario that the system has no network access and no alternative. In most exam scenarios, apt-get install -f is the correct answer."

Commonly Confused With

dpkgvsAPT (Advanced Package Tool)

APT is a high-level package management system that uses dpkg as its backend. APT automatically resolves dependencies and downloads packages from repositories, while dpkg operates directly on .deb files without dependency resolution. APT calls dpkg to perform the actual installation, but adds intelligence on top.

You use apt install curl to install curl and all its dependencies automatically. You use dpkg -i curl.deb if you already have the file and know all dependencies are installed.

dpkgvsRPM (RPM Package Manager)

RPM is the package manager for Red Hat-based systems like Fedora, CentOS, and RHEL. It uses .rpm files instead of .deb files. The commands are similar but different: rpm -ivh package.rpm is the equivalent of dpkg -i package.deb. The concepts are analogous but the tools are not interchangeable across distributions.

On an Ubuntu system, you use dpkg. On a CentOS system, you use rpm. They both install packages, but the file format and database location differ.

dpkgvsSnap

Snap is a different package management system developed by Canonical for Ubuntu. Snap packages are self-contained and include all dependencies, so they do not have dependency issues. dpkg does not manage snap packages; they use the snap command. Unlike dpkg, snap automatically updates packages and uses sandboxing for security.

You install a snap with sudo snap install hello-world. You install a .deb with sudo dpkg -i hello-world.deb. They are completely separate systems.

dpkgvsdpkg-deb

dpkg-deb is a related tool that performs operations on .deb files without interacting with the dpkg database. It can extract, inspect, and build .deb files but does not install them. dpkg itself can call dpkg-deb for extraction, but they are not the same. Beginners sometimes think dpkg-deb is the same as dpkg.

Use dpkg-deb -c package.deb to list the contents of a .deb file without installing it. Use dpkg -i to actually install it.

Step-by-Step Breakdown

1

Download or obtain a .deb package

The first step is to have a .deb file ready. This could be downloaded from a website, transferred from another machine, or built by you. The .deb file is a standard archive that contains all the files needed for the software, plus metadata and scripts.

2

Run dpkg -i with the package file

You execute the command sudo dpkg -i packagename.deb. The -i flag stands for install. dpkg reads the .deb file and begins the installation process. It checks for any pre-existing version and whether the package architecture matches your system. If the package is already installed, it will upgrade it.

3

Extraction and pre-installation scripts

dpkg extracts the files from the archive into temporary locations and runs any pre-installation scripts (preinst) that the package includes. These scripts can set up users, stop services, or perform other checks before files are placed in their final locations.

4

Copy files to their target locations

After preprocessing, dpkg copies the package files to their designated directories according to the filesystem hierarchy standard. For example, binaries go to /usr/bin, libraries to /usr/lib, and configuration files to /etc. dpkg also updates its database with the new file locations.

5

Post-installation configuration

Once files are in place, dpkg runs the post-installation scripts (postinst) to complete the setup. This may involve starting services, creating symbolic links, or setting up systemd units. The package is now marked as 'installed' in the dpkg database. If dependencies are missing, dpkg stops here and reports an error.

Practical Mini-Lesson

dpkg is a low-level tool that works directly with the dpkg database and .deb archives. As a system administrator, you will rarely use dpkg as your primary install method because APT does a better job of handling dependencies and updates.

However, dpkg is indispensable in specific contexts. For example, when you are managing an air-gapped server that cannot access the internet, you must download .deb packages on a connected machine and transfer them via USB or network share.

Then you use dpkg to install them. Another common situation is when you build your own .deb packages from source code or custom software. Developers often create .deb files for internal tools, and dpkg is the standard way to install them during testing and deployment.

You also need dpkg when APT is broken. Sometimes the APT database gets corrupted due to an interrupted installation or manual file modifications. In those cases, you can use dpkg --configure -a to attempt to configure any partially installed packages.

If that fails, you may need to manually remove problematic packages using dpkg --remove --force depends. Professionals also use dpkg to query the system. Need to know which package installed a particular file?

Use dpkg -S /path/to/file. Want to see all packages related to a keyword? Use dpkg -l | grep keyword. Want to confirm a package's version? Use dpkg -s packagename. These queries are faster than using APT for such tasks.

One important detail is that dpkg does not run automatically on a schedule. It only does what you tell it. So if you install a package and it requires a database server that is not running, dpkg will not start it for you.

You must ensure services are operational after installation. Also, dpkg does not handle updates from repositories. If you use dpkg to install a newer version of a package that is already managed by APT, APT might later downgrade it during an update unless you hold the package.

To prevent this, you can use dpkg --set-selections to mark a package as held. In practice, always prefer APT for routine tasks, but keep dpkg in your toolkit for emergencies and custom packages. Mastery of dpkg also helps you understand the underlying mechanics of Linux package management, which is a sign of a skilled administrator.

Troubleshooting Clues

Symptom:

Symptom:

Symptom:

Symptom:

Memory Tip

Think of DPKG as 'Do Package, Keep Going', it installs the package but keeps going only if dependencies are already met. If they are missing, it stops and cries for help.

Covered in These Exams

Current Exam Context

Current exam versions that test this topic — use these objectives when studying.

Legacy Exam Context

Older materials may mention these exam versions, but learners should use the current objectives for their target exam.

XK0-005XK0-006(current version)

Related Glossary Terms

Quick Knowledge Check

1.Which command is used to install a .deb package file named myapp.deb?

2.What does the dpkg -L command do?

3.After using dpkg -r to remove a package, what happens to its configuration files?

4.Which of the following is a key limitation of dpkg?

Frequently Asked Questions

What is the difference between dpkg and APT?

dpkg is a low-level tool that installs .deb files directly but does not handle dependencies. APT is a higher-level tool that automatically resolves dependencies, downloads packages from repositories, and uses dpkg underneath to perform the actual installation.

Can dpkg install packages from the internet?

No, dpkg only works with .deb files that are already present on your system. To download and install packages from the internet, you need to use APT or another front-end tool.

How do I fix a broken package with dpkg?

First, try sudo dpkg --configure -a to configure all partially installed packages. If that does not work, use sudo apt-get install -f to fix broken dependencies. In extreme cases, you may need to remove the problematic package with sudo dpkg --remove --force-depends packagename.

How do I see all installed packages with dpkg?

Use the command dpkg -l (lowercase L). This will list all installed packages along with their version, architecture, and a brief description.

What is a .deb file?

A .deb file is a Debian software package format. It is a compressed archive that contains the software binaries, configuration files, metadata, and installation scripts needed for a program to run on Debian-based systems.

Should I use dpkg or APT for daily package management?

Use APT for routine tasks because it handles dependencies and updates automatically. Use dpkg only when you need to install a .deb file directly, when APT is broken, or for specific queries like finding which package owns a file.

Summary

dpkg is the fundamental package management tool on Debian and Ubuntu Linux systems, responsible for installing, removing, and querying .deb packages. It operates directly on package files and maintains a database of installed software, but it does not automatically resolve dependencies or download packages from the internet.

This limitation makes dpkg less convenient than APT for everyday use, but it also makes it an essential fallback tool for offline installations, system recovery, and custom package deployment. Understanding dpkg is critical for IT certification exams such as CompTIA Linux+ and LPIC-1, where you will be tested on command syntax, output interpretation, and troubleshooting scenarios. Common mistakes include confusing dpkg -r with dpkg -P, misreading status flags, and using force options unnecessarily.

The key takeaway for exams is to remember that dpkg is the low-level worker, APT is the smart manager, and each has its place. Practice with a virtual machine to build muscle memory for commands like dpkg -i, dpkg -l, dpkg -L, and dpkg -s. Mastering dpkg not only helps you pass exams but also gives you the confidence to handle real-world package management challenges on Linux servers.