Debian Package Management, Part 1: A User's Guide
Debian has one of the most powerful and versatile package management systems of any Linux distribution. It is also incredibly cryptic. However, once you start using it, I promise it does get easier.
Debian's basic package management tool is dpkg. dpkg is actually built on top of dpkg-deb, but I'll get into that later. There are a suite of tools built on top of dpkg, including dselect, apt-get, console-apt and others. This article functions as a HOWTO, providing commands and instructions on ways to manipulate dpkg and receive pertinent information about your Debian, or Debian-based system. I'm not going to cover everything, but enough so that, you'll be able to use the package management capabilities of your Debian-based system with proficiency.
Every Debian package is an archive ending with the extension “.deb”. For this article, I'll refer to a package as a “deb”. debs are usually named in the following manner:
For the examples in this article, I use “foobar.deb” when a deb needs to be substituted, and “foobar” when a package name is to be substituted.
For those familiar with the Red Hat Package Management (RPM) system, dpkg's approach to package management is much different in its approaches. RPM is a file-based package manager, meaning it checks for specific files required by a package like libgtk-1.2.so.0. In contrast, dpkg is package-based, so it checks to see if you have a specific package, such as libgtk1.2.
Most people will not use dpkg for day-to-day package management, but it is an incredibly powerful and useful tool. Dpkg's most basic action is to install a package, which is done with the command dpkg -i foobar.deb. This will install the package, while backing up any existing versions of the package. The command dpkg -i -R /foo/bar will install all of the debs in a directory.
We all know from experience that sometimes a package won't install properly or refuses to configure. Or maybe the user aborted the configure process. dpkg has some helpful tools for making the configuration process easier. In these instances, dpkg -configure <package> will finish the configuration of the specific package, and dpkg --configure --pending will configure all packages with configuration pending.
It is just as easy to remove packages with a few simple commands. Using either dpkg -r <package> or dpkg -remove <package> will remove a package and leave its configuration files. If you want to remove all files related to the package, including its configuration files, use the command dpkg --purge <package>.
Debian package management provides several ways to find information on what packages are currently installed and what files each package provides. One way to sort packages is by using a pattern, facilitated with the command dpkg-l <pattern>. If necessary, a wildcard can be used as the <pattern>. Using dpkg -l alone will provide a list of all the packages currently installed on your system.
Using Debian package management also allows you to see what files were installed by a specific package with the command dpkg -L <package>. Alternatively, to find out which package owns a file use dpkg -S <file>. These searches can also be done with a pattern, including wildcards.
When you need to get information about a particular deb, this list of commands is helpful:
dpkg -I foobar.deb lists detailed information about a debdpkg -c foobar.deb lists the contents of a deb, similar totar's -c option.dpkg -x foobar.deb <dir> extracts a deb intothe specified directorydpkg -X foobar.deb <dir> lists the files asit extracts them, like tar's-v option
In addition to all of the useful information that dpkg accesses for productive package management, it also has a rich set of options for screwing up your package management system royally. To quote dpkg's manpage, “Warning: These options are mostly intended to be used by experts only. Using them without fully understanding their effects may break your whole system.” I won't cover this set of options here, as you should never really need to use them. However, if you ever need to force dpkg to ignore dependencies, overwrite files installed by other packages, ignore conflicts or anything else the Debian package management system is designed to prevent, look at man dpkg.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- ServersCheck's Thermal Imaging Camera Sensor
- The Italian Army Switches to LibreOffice
- Petros Koutoupis' RapidDisk
- Linux Mint 18
- Oracle vs. Google: Round 2
- The FBI and the Mozilla Foundation Lock Horns over Known Security Hole
- Ben Rady's Serverless Single Page Apps (The Pragmatic Programmers)
- Privacy and the New Math
Until recently, IBM’s Power Platform was looked upon as being the system that hosted IBM’s flavor of UNIX and proprietary operating system called IBM i. These servers often are found in medium-size businesses running ERP, CRM and financials for on-premise customers. By enabling the Power platform to run the Linux OS, IBM now has positioned Power to be the platform of choice for those already running Linux that are facing scalability issues, especially customers looking at analytics, big data or cloud computing.
￼Running Linux on IBM’s Power hardware offers some obvious benefits, including improved processing speed and memory bandwidth, inherent security, and simpler deployment and management. But if you look beyond the impressive architecture, you’ll also find an open ecosystem that has given rise to a strong, innovative community, as well as an inventory of system and network management applications that really help leverage the benefits offered by running Linux on Power.Get the Guide