Linux Package Management: APT, DPKG, and Beyond
Master Linux package management across Debian-based systems including APT, DPKG, repository configuration, dependency resolution, and troubleshooting.
Managing Software on Linux
Every security tool on Kali Linux — from Nmap to Metasploit — is installed through the package management system. Knowing how to install, update, and troubleshoot packages is a core operational skill that you will use daily. This guide covers APT, DPKG, and related tools so you can keep your environment up to date and resolve dependency issues without breaking your system.
Prerequisites
Familiarity with basic Linux commands and terminal navigation. Root or sudo access for package operations.
DPKG — The Foundation
DPKG is the low-level tool that directly installs, removes, and queries .deb packages.
Basic DPKG Commands
Direct Debian archive manipulation relies on dpkg -i to unpack and configure local packages, dpkg -r to remove installed binaries while keeping configurations, and dpkg -l to query the local database for package status and architecture flags. Universal package workflows can also be managed via isolated containerized snaps using snap install or Python runtime environments using pip install.
sudo dpkg -i package.deb # Install a .deb file
sudo dpkg -r package_name # Remove a package (keep configs)
sudo dpkg -P package_name # Purge a package (remove everything)
dpkg -l # List installed packages
dpkg -L package_name # List files installed by a package
dpkg -S /path/to/file # Find which package owns a file
DPKG Troubleshooting
sudo apt --fix-broken install # Fix missing dependencies
APT — The Package Manager
APT works with DPKG to provide dependency resolution, repository management, and a user-friendly interface.
Repository Configuration
APT works with sources in /etc/apt/sources.list:
deb http://http.kali.org/kali kali-rolling main non-free contrib
Essential APT Commands
Primary APT operations include repository index synchronization via apt update, package upgrades with apt upgrade, installing binaries through apt install, binary removal with apt remove, configuration file elimination via apt purge, and orphaned dependency cleanup using apt autoremove. Package discovery and inspection are handled by apt search, metadata display via apt show, and installed package enumeration with apt list.
sudo apt update # Update package index
sudo apt upgrade # Upgrade all packages
sudo apt full-upgrade # Full upgrade with dependency changes
sudo apt install nmap # Install a package
sudo apt remove nmap # Remove a package
sudo apt purge nmap # Purge a package and configs
apt search "web scanner" # Search for packages
apt show nmap # Show package information
apt list --installed # List installed packages
sudo apt autoremove # Remove unneeded packages
sudo apt clean # Clear package cache
APT Update Pipeline
apt update — Downloads package indexesapt list --upgradable — Shows available updatesapt upgrade — Upgrades packagesapt full-upgrade — Handles changing dependenciesDependency Resolution
apt install --dry-run wireshark # Simulate install without changes
Adding Third-Party Repositories
# Method 1: add-apt-repository
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
# Method 2: Manual repository file
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable" | sudo tee /etc/apt/sources.list.d/docker.list
# Method 3: Direct .deb download
wget https://example.com/software.deb
sudo dpkg -i software.deb
sudo apt --fix-broken install
Package Hold and Pinning
sudo apt-mark hold package_name # Prevent package from being upgraded
sudo apt-mark unhold package_name # Unhold a package
apt-mark showhold # Show held packages
Real-World Examples
Installing Metasploit: sudo apt install metasploit-framework
Minimal install: sudo apt install --no-install-recommends package
Upgrading Kali: sudo apt update && sudo apt full-upgrade -y
Common Mistakes
Running apt upgrade without apt update first. Using unstable repos without pinning. Forgetting GPG keys for third-party repos.
Best Practices
Always run sudo apt update before sudo apt upgrade. Use apt search and apt show before installing. Use --dry-run to preview changes. Remove unused packages with sudo apt autoremove. Verify GPG keys when adding repositories.
Related Tools
snap — Canonical's container package system. flatpak — Sandboxed applications. gdebi — GUI .deb installer. aptitude — Alternative APT interface.
Related Articles
Summary
Package management on Debian systems uses DPKG (low-level .deb handling) and APT (high-level dependency resolution). Essential commands: apt update,apt install, apt upgrade, apt remove. Understanding both tools is fundamental to maintaining a healthy Linux system.
Knowledge Check
sudo apt --fix-broken install do?Frequently Asked Questions
Continue Learning
SSH Fundamentals: Secure Remote Access and Administration
Learn SSH for secure remote access including key-based authentication, configuration, tunneling, port forwarding, and security hardening.
Linux · BeginnerLinux Process Management: Monitoring and Controlling Processes
Learn to manage Linux processes effectively including monitoring tools, signals, priority control, background jobs, and automation with systemd.
Linux · IntermediateLinux Terminal Guide: Advanced Shell Skills for Professionals
Advanced Linux terminal techniques including shell customization, multiplexing, productivity tools, and scripting best practices.
Linux · BeginnerCommand Line Essentials: Mastering the Terminal for Security Work
Essential command line skills for cybersecurity professionals including navigation, text processing, scripting, and automation.
Related Security Tools
Nikto
Learn how to use Nikto, an open-source web server scanner written in Perl and pre-installed on Kali Linux, to audit servers you own or have written permission to test. Its 6700+ checks for potentially dangerous files and programs, plus tests for outdated software and misconfigurations, highlight issues that need verification.
Information GatheringNmap
Learn how to use Nmap, the free open-source network scanner: run your first port scan, discover live hosts, detect services and operating systems, and check for vulnerabilities with NSE scripts — a beginner tutorial for Kali Linux.
Sniffing & SpoofingWireshark
Wireshark tutorial for beginners: capture packets, read the three panes, filter traffic and follow TCP streams — a hands-on guide to the world's foremost network protocol analyzer.
Post ExploitationEvil-WinRM
Learn how to use Evil-WinRM, a Ruby-based client for the Windows Remote Management (WinRM) protocol. This guide covers installation, your first connection, password, pass-the-hash and Kerberos authentication, file transfers and script execution, all for use in authorized lab environments.