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.
|Designing Electronics with Linux||May 22, 2013|
|Dynamic DNS—an Object Lesson in Problem Solving||May 21, 2013|
|Using Salt Stack and Vagrant for Drupal Development||May 20, 2013|
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
- RSS Feeds
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Designing Electronics with Linux
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- A Topic for Discussion - Open Source Feature-Richness?
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Validate an E-Mail Address with PHP, the Right Way
- What's the tweeting protocol?
- Kernel Problem
3 hours 44 min ago
- BASH script to log IPs on public web server
8 hours 11 min ago
11 hours 47 min ago
- Reply to comment | Linux Journal
12 hours 19 min ago
- All the articles you talked
14 hours 43 min ago
- All the articles you talked
14 hours 46 min ago
- All the articles you talked
14 hours 47 min ago
19 hours 12 min ago
- Keeping track of IP address
21 hours 3 min ago
- Roll your own dynamic dns
1 day 2 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi
It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?