Everyday Guidebooks
Cover of Linux How-To

Cybersecurity & IT

Linux How-To: Manage Software Packages

A Practical Guide to Repositories, Updates, Dependencies, and Package Security

by Todd Michael

Available now

Installing a package is easy. Knowing where it came from, what it depends on, and how to update or remove it safely takes a little more practice.

Linux How-To: Manage Software Packages gives aspiring administrators a focused path through everyday package-management work on Debian- and Red Hat-based systems. Follow examples using APT, dpkg, DNF, and RPM as you search repositories, inspect installed files, verify package sources, resolve common dependency problems, and plan updates with less risk.

Hands-on exercises let you compare commands across system families and practice diagnosing mistakes in a disposable lab environment. You’ll also learn to read transaction output, recognize when a proposed change needs closer review, and document your work.

Whether you are building job skills or reviewing a topic for a Linux certification, this practical guide belongs on your shortlist of linux how to books. Basic command-line familiarity is recommended; no certification exam is required.

Contents
  1. 1. Build a Safe Package-Management Lab
  2. 2. How Linux Packages Fit Together
  3. Debian-family system
  4. RPM-based system
  5. 3. Find and Evaluate Packages
  6. 4. Install Software with APT and dpkg
  7. 5. Install Software with DNF and RPM
  8. 6. Inspect Installed Software
  9. 7. Understand and Configure Repositories
  10. 8. Check Package Sources and Signatures
  11. 9. Plan and Apply Safe Updates
  12. 10. Manage Versions and Upgrade Decisions
  13. 11. Remove Packages and Clean Up
  14. Debian family
  15. Red Hat family
  16. Debian family: inspect the intended package first
  17. Red Hat family: inspect the intended package first
  18. 12. Diagnose Dependency and Transaction Problems
  19. 13. Investigate Repository and Trust Failures
  20. Begin With the Exact Failure
  21. Separate Network Access From Repository Configuration
  22. Inspect the Configured Sources
  23. Recognize Stale and Inconsistent Metadata
  24. Investigate Trust Failures Without Bypassing Them
  25. Guided Lab: Isolate a Failing Source
  26. When the Failure Persists
  27. 14. Package-Management Practice Scenarios
  28. Other Books by Todd Michael

Read a sample: 1. Build a Safe Package-Management Lab

The best place to learn package management is a system you can afford to break. Installing a utility may look like a small change, but the package manager can also install dependencies, replace files, update shared libraries, or start services. Later exercises will ask you to examine those decisions and recover from problems. A disposable lab gives you room to do that without experimenting on a work laptop or production server.

This chapter builds a foundation for the rest of the book: one Debian-based virtual machine and one Red Hat-based virtual machine, administrative access on each, a record of their initial state, and a checkpoint you can use for recovery. You do not need to master virtualization first. You do need to know which computer is receiving each command and how to return the lab to a known state.

The examples in this book use two package-management families:

- Debian-based systems, such as Debian and Ubuntu, commonly use APT for repository-aware package management and dpkg for lower-level package operations. - Red Hat-based systems, such as Fedora and supported releases of distributions in the Red Hat Enterprise Linux family, commonly use DNF for repository-aware management and RPM for lower-level operations.

For a straightforward lab, use a current, supported Debian or Ubuntu release for the first virtual machine and a current, supported Fedora release or another suitable Red Hat-family distribution for the second. Download installation media from the distribution’s official site. Follow its published instructions for verifying the download where available; an unexpected download should not be the foundation of a security-conscious lab.

Commands, package names, default repositories, and output vary between releases. DNF itself may differ by version, and a distribution can customize a tool’s behavior. The book’s commands illustrate common workflows, not a promise that every line of output will match your screen. When an option is unavailable or a package name differs, consult the installed tool’s help and the documentation for your distribution and release.

You may use an existing hypervisor on your computer or a reputable hosted virtualization service. The interface will differ, but the decisions are similar: create a virtual disk, attach installation media, install the operating system, and provide enough resources for it to run comfortably. Two virtual CPUs, 2–4 GB of memory, and a virtual disk of at least 20 GB are reasonable starting points for a small command-line lab, subject to the distribution’s requirements and your host’s capacity. You can run the machines one at a time if resources are limited.

Use separate virtual machines rather than trying to combine both package families in one installation. Name them something unmistakable, such as debian-lab and redhat-lab. These names are labels for your practice environment; they do not have to match a particular distribution.

Create the first virtual machine in your hypervisor and attach the Debian-family installation image. Choose a normal installation onto the virtual disk, not a physical disk containing data you need. During installation, create a regular user account with a password you can remember. Enable administrative access for that account as described in the next section.

Repeat the process with the Red Hat-family image. A minimal or server-oriented installation is sufficient for the exercises, provided you have a shell, networking, and the package-management tools supplied by the distribution. A graphical desktop is optional.

Keep the lab isolated from systems you do not intend to change. A network mode that allows outbound access through the host, often called NAT, is a useful default for downloading packages. It is not a substitute for checking your hypervisor’s network settings: avoid exposing lab services to other networks unnecessarily, and do not configure bridged networking simply because an example elsewhere uses it.

Before continuing, confirm that you can open a console for each machine, sign in as your regular user, and shut it down and start it again. The hypervisor’s console is especially useful if a later network or SSH configuration problem prevents remote access.

Package database changes generally require administrative privileges. Routine observation does not. Working as a regular user and elevating only the commands that need it makes the boundary visible and reduces the chance that an ordinary typing mistake changes the system.

On each machine, check whether sudo is available:

bash command -v sudo

If the command prints a path, test your account’s authorization:

bash sudo -v

You may be asked for your user password. A successful command ordinarily returns without additional output. If sudo is missing or your account is not authorized, follow the installation or administration documentation for that distribution to grant your lab user appropriate access. Some installations configure sudo during setup; others require an administrator to install or configure it. Do not repeatedly guess passwords or change privilege settings you do not understand.

Where the installation provides a root account, you may be able to use su - and the root password to perform initial configuration. Return to the regular account afterward. The examples in this book use sudo for commands that require elevation; omit it only when you are deliberately working in an already privileged shell.

Check which account and machine you are using:

bash whoami hostname

Make a habit of running these commands when switching between terminals. They provide a simple check, but they are not proof that you are on the intended virtual machine if names are duplicated. Use your hypervisor’s console or window labels as an additional…

More Cybersecurity & IT

Cover of The White Hat Bible, Volume 1The White Hat Bible, Volume 1Available nowCover of The White Hat Bible, Volume 2The White Hat Bible, Volume 2Available nowCover of The White Hat Bible, Volume 3The White Hat Bible, Volume 3Available nowCover of The White Hat Bible, Volume 4The White Hat Bible, Volume 4Available nowThe White Hat Bible, Volume 5Available nowCover of The White Hat Pocket GuideThe White Hat Pocket GuideAvailable now

About Todd Michael

Todd Michael is an American author and the founder of ToddMichael.tv. He writes practical, plain-English books on money, health, preparedness, technology, games, humor and more.

About the author Todd Michael · Todd Michael’s author site

Part of the ToddMichael.tv network.