Boot and Hardware Management
Linux Package Management
The course is part of this learning path
"Linux Installation and Package Management" is the third course in this Linux certification series. You'll learn how to control the Linux boot process, how to understand and manage disk partitions and filesystems, and how Linux uses kernel libraries to manage hardware peripherals. We'll also take a closer look at the two most widely used Linux software package management systems: dpkg and rpm.
If you have thoughts or suggestions for this course, please contact Cloud Academy at email@example.com.
As we mentioned in the previous video on shared libraries, the various Linux package management systems do a spectacular job handling installation and dependency tracking for us. Of course, they also do much more. Since these repositories are closely curated, you can be confident that the software you download will be useful, fully functional and malware-free. And considering just how many thousands of software packages these repositories contain, the fact that everything works as well as it does is something of a marvel.
Managing packages on Debian Linux systems using dpkg and apt-get
Linux distributions mostly align themselves with one or another of the larger package management systems. The two largest of these - Debian's dpkg, and RPM - serve some of the most popular modern distributions: dpkg can count Debian, Ubuntu, and Linux Mint among its "customers," while RPM (whose "r" originally stood for Red Hat) serves Red Hat, Fedora and openSUSE, among others. Through this video and the next, we'll focus specifically on these two managers - which just happens to line up nicely with the exam expectations.
Besides maintaining the software repositories themselves, to ensure easy compatibility, package managers also establish rules and practical guidelines for how the packages are built.
Thus, a .deb package meant for dpkg won't work on a system that's looking for .rpm. That's seldom a problem, since most software that's available on one, will be similarly accessible through the other. But it does mean that the fine working details of the two package managers will be a bit different, and you will definitely be expected to be familier with them for the exam. So let's take a good look at Debian's dpkg - and leave RPM for the next video.
You can install, remove, status-check and generally manage your software using the dpkg command and its arguments. However, there are a number of frontend programs - each with its own unique features - that can do a great deal more. We'll explore three of these: apt, aptitude, and synaptic a bit later. In the meantime, we'll go through some of dpkg's own functions. dpkg's default behavior is controlled by the dpkg.cfg file found in the /etc/dpkg directory. This particular copy has only two settings concerning package signatures and log locations. If you've directly downloaded a .deb package you can install it with root authority using dpkg -i
We'll use this fictitious package to illustrate Debian naming standards, where my_package is the package name, the number is the package version, i386 is the architecture it was written for (32-bit, in this case), and deb identifies it as a Debian package. You can use dpkg...to unpack package files without actually going through configuration process. I would imagine this might be useful if you plan to manually create a non-standard configuration profile.
You can remove a package that's currently installed, identifying it through its short name, using dpkg -r. To remove the package files AND its user settings, use purge. And dpkg-reconfigure will reconfigure an already-unpacked package. You can use debconf if you want to simply display a package's configuration:
To review. You can manage local software packages using dpkg. dpkg defaults are kept in the dpkg.cfg file. You can install a package using dpkg -i. dpkg --unpack will unpack but not install. dpkg -r will remove a package, dpkg -P will purge it, and dpkg-reconfigure will allow you to configure a package's settings over again
Now, as you might have noticed, dpkg only works with local packages, and not external repositories. The best way to access the wide world of Linux software, therefore, is through APT (which stands for Advanced Packaging Tool). You tell Linux how to find the Debian repositories through the sources.list file that's kept in the /etc/apt directory.
You can see pairs of links to Internet URLs: one of each pair called deb - obviously for Debian - and the other deb-src. Each link points to the repo associated with a particular release - in this case Ubuntu's Trusty - and a specific category. We can see main, universe, and multiverse here. Each of those contains a different range of programs. deb URLs will contain program packages including binary files, while deb-src sites contain program source code files. If you want to manually add a previously inaccessible repo source - perhaps a trusted third party source - this is the file you will update. Just be careful to get the syntax right or it might not work.
The most popular command line tool for software management is apt-get. apt-get update will tell your local apt system about any new package information available from appropriate remote repositories. apt-get install, followed by the package name, will install a package. apt-get upgrade will search for and apply all available package upgrades. apt-get dist-upgrade is similar to apt-get upgrade but, in addition, will also intelligently remove dependencies made unnecessary by overall changes. apt-get remove will, predictably, remove a package you no longer need. Finally, running apt-get install using the -s flag will display dependency and installation information, but without installing:
Another way to view package data is through apt-cache. apt-cache stats will display some package information about a specified package. apt-cache depends will display package dependencies and apt-cache unmet will display any unmet dependencies associated with a specificed package. Running apt-cache unmet without specifying a package will output all unmet dependencies on the whole system. Be prepared to go through a lot of reading!
Besides running apt from the command line, you can also use Aptitude, which is a terminal-based interface for people who aren't yet comfortable with apt-get but too embarrassed to use a true GUI interface like Synaptic. To be honest, I'm not really sure what value Aptitude has these days (although, now that I've said that, I'm sure that I'll receive hate mail from it's supporters), but the LPI exam expects you to know about it. Hitting the ? key will give you a help page, and hitting q will exit. What more could you possibly need?
Let's review. The sources.list file tells Linux where to find your remote software repositories. Links in the sources.list file point to repo URLs, including repo type, address, distribution, and category. apt-get update will update information about available upstream packages. You can install packages using apt-get install, upgrade all packages using apt-get upgrade or apt-get dist-upgrade, apt-get remove will, predictably, remove a package you no longer need. apt-get install -s will display package information but not install it, and apt-cache stats, depends, or unmet will also display package information.
Finally, Synaptic will nicely manage your packages from the Desktop. Besides doing just about everything apt-get can do, Synaptic is also a great research tool, allowing you to search for packages [chess] and look up file and version information.
About the Author
David taught high school for twenty years, worked as a Linux system administrator for five years, and has been writing since he could hold a crayon between his fingers. His childhood bedroom wall has since been repainted.
Having worked directly with all kinds of technology, David derives great pleasure from completing projects that draw on as many tools from his toolkit as possible.
Besides being a Linux system administrator with a strong focus on virtualization and security tools, David writes technical documentation and user guides, and creates technology training videos.
His favorite technology tool is the one that should be just about ready for release tomorrow. Or Thursday.