Sysadmin training
Get a taste of the Linux Foundation’s System Administration course, as Jonni Bidwell brushes up on how to manage software the Linux way
The Linux Foundation’ s Essentials of Linux System Administration co ur se,LFS201,isfu ll of knowledge. It consists of 42 chapters, with short knowledge tests and longer lab assignments. In this taster we introduce the topic of package management systems (chapter 27) before skipping to a primer on Debian’s APT (chapter 32).
It’s necessary to introduce order into the way software is installed, updated and removed on Linux systems. Package management systems provide a clean way to achieve that goal and can prevent systems from descending into chaos, fossilisation or breakage with time. Furthermore, they provide a method to verify that the software on the system hasn’t been corrupted, either maliciously or by accident. An essential function of Linux distributors is to develop and maintain the packages, and to ensure that dependencies are properly maintained over time.
Package management systems supply the tools that enable system administrators to automate installing, upgrading, configuring and removing software packages in a known, predictable and consistent manner. These systems achieve the following:
Gather and compress associated software files into a single package (archive), which may require one or more other packages to be installed first; Allow for easy software installation or removal; Can verify file integrity via an internal database; Can authenticate the origin of packages; Facilitate upgrades; Group packages by logical features; and Manage dependencies between packages.
A given package may contain executable files, data files, documentation, installation scripts and configuration files. Also included are metadata attributes such as version numbers, checksums, vendor information, dependencies, descriptions and so on. Upon installation, all that information is stored locally in an internal database that can be queried for version status and update information.
Software package management systems are widely seen as one of the biggest advancements Linux brought to enterprise IT environments. By keeping track of files and metadata in an automated, predictable and reliable way, system administrators can use package managements systems to make their installation processes scale to thousands of systems without requiring manual work on each individual system. Features include: Automation – no need for manual installs and upgrades; Scalability – install packages on one or 10,000 systems; Repeatability and predictability; and Security and auditing;
Packages come in several different types: Binary packages contain files ready for deployment, including executable files and libraries. These are architecture dependent and must be compiled for each type of machine.
Source packages are used to generate binary packages. One should always be able to rebuild a binary package (for example, by using rpmbuild --rebuild on RPM-based systems) from the source package. One source package can be used for multiple architectures.
Architecture-independent packages contain files and scripts that run under script interpreters, as well as documentation and configuration files.
Meta-packages are groups of associated packages that collect everything needed to install a relatively large subsystem, such as a desktop environment or an office suite.
Binary packages are the ones that system administrators have to deal with most of the time.
Double the fun
On 64-bit systems that can run 32-bit programs, one may have two binary packages installed for a given program, perhaps one with x86_64 or amd64 in its name, and the other with i386 or i686 in its name. Source packages can be helpful in keeping track of changes and source code used to come up with binary packages. They’re usually not installed on a system by default, but can be retrieved from the vendor.
There are two levels to packaging systems: Low-level utility – this simply installs or removes a single
package or a list of packages, each one of which is individually and specifically named. Dependencies aren’t fully handled, only warned about. So if another package needs to be installed first the installation will fail, and if the package is needed by another package, its removal will fail. The rpm and dpkg utilities play this role for the packaging systems that use them.
High-level utility – this solves the dependency problems. If another package or group of packages needs to be installed before software can be installed, such needs will be satisfied. If removing a package interferes with another installed package, the administrator will be given the choice of either aborting, or removing all affected software.
The yum , dnf and zypper utilities take care of the dependency resolution for rpm systems, and apt-get ,
apt-cache and other utilities take care of it for dpkg systems.
How terribly APT
For use on Debian-based systems, the APT (advanced packaging tool) set of programs provides a higher level of intelligent services for using the underlying dpkg program, and plays the same role as yum on Red Hat-based systems. The main utilities are apt-get and apt-cache . It can automatically resolve dependencies when installing, updating and removing packages. It accesses external software repositories, synchronising with them and retrieving and installing software as needed.
Queries are done using the apt-cache utility. To search the repository for a package named apache2 , use: $ apt-cache search apache2
To display basic information about the apache2 package, carry out the following: $ apt-cache show apache2
To display more detailed information about the apache2 package, type: $ apt-cache showpkg apache2
To list all dependent packages for apache2 : $ apt-cache depends apache2
Search the repository for a file named apache2.conf: $ apt-file search apache2.conf
List all the files in the apache2 package: $ apt-file list apache2
The apt-get program is the workhorse of installing, removing and upgrading packages.
The indices of available packages are fetched from the location(s) specified in /etc/apt/sources.list. To synchronise the package index files with their repository sources, use the following instruction: $ sudo apt-get update
If you want to install new packages or update an already installed package, type: $ sudo apt-get install [package] Remove a package from the system without removing its configuration files: $ sudo apt-get remove [package] Remove a package from the system and its configuration files as well: $ sudo apt-get --purge remove [package] Apply all available updates to packages already installed: $ sudo apt-get upgrade
Carry out a smart upgrade that will do a more thorough dependency resolution and remove some obsolete packages and install new dependencies. This will not, as is commonly misunderstood, update to a new version of the Linux distro: $ sudo apt-get dist-upgrade
Note that you must update before you upgrade, unlike with yum (or dnf ), where the update argument does both steps, updating the repositories and then upgrading the packages. This can be confusing to habitual yum users on Debian-based systems.
To get rid of any packages no longer required, such as older Linux kernel versions: $ sudo apt-get autoremove
Clean out cache files and any archived package files that have been installed: $ sudo apt-get clean This can save a lot of space.
There’s much more (around 40 chapters in fact) to this course and anyone wishing to brush up their skills, possibly with a view to securing a sysadmin job, would be well-advised to invest in it.