Chapter 5: Package Management & Text Processing

42 min read ▅▅ Intermediate Updated July 2026

Learning Objectives

  • Understand Linux packages, formats, and repositories.
  • Install and query packages with rpm, dnf, and apt.
  • Filter and transform text with grep, sed, awk, and cut.
  • Combine package and text tools in everyday admin pipelines.

Prerequisites

Complete Chapters 1–4 before starting this chapter.

1. Introduction

This chapter covers two skills you use constantly as an admin: installing software through package managers, and filtering logs or config files with text tools. Most of the chapter focuses on packages; the final section covers the grep/sed/awk/cut patterns you will reuse in later chapters.

2. What Is a Linux Package?

A package is a compressed archive containing everything needed to install an application.

Application ──► Executables | Libraries | Configuration Files | Documentation | Metadata
              

Examples include vim, git, curl, nginx and OpenSSH.

3. Why Package Managers Exist

  • Install software consistently.
  • Resolve dependency packages automatically.
  • Apply updates and security fixes.
  • Verify package integrity.
  • Remove software cleanly.

4. Common Package Formats

FormatUsed ByDescription
RPMRHEL, Rocky, AlmaLinux, FedoraRed Hat Package Manager format.
DEBDebian, UbuntuDebian package format.
Source CodeAllCompiled manually.
FlatpakMultiple distributionsSandboxed desktop packages.
SnapUbuntu and othersUniversal package format.
AppImageMultiple distributionsPortable application package.

5. Package Managers by Distribution

DistributionPackage Manager
RHEL / Rocky / AlmaLinuxrpm, yum, dnf
Fedoradnf
Debian / Ubuntuapt, dpkg

6. Understanding Repositories

A repository is a trusted software source containing packages and metadata. These can include official channels, third-party extensions, localized offline networks, or enterprise baseline mirror servers.

7. Useful Information Commands

cat /etc/os-release # Display distribution information
hostnamectl # Show system details
uname -r # Display kernel version
which dnf apt rpm # Locate package manager binaries

8. Hands-on Practice (Package Query)

  1. Identify your Linux distribution and kernel version.
  2. Determine whether your system uses RPM or APT binaries.
  3. Locate the package manager path cleanly using which.

9. Installing & Querying RPM Packages Directly

rpm -ivh package.rpm # Install a local RPM package
rpm -qa # List all installed packages...
rpm -qi openssh # Display complete package information
rpm -ql openssh # List all files installed by this package
rpm -qf /usr/bin/ssh # Identify which package owns a specific file path
rpm -V openssh # Verify package integrity against repository bounds

10. Automated Dependency Management (dnf, apt)

While low-level tools like `rpm` and `dpkg` track single packages, wrappers like `dnf` and `apt` parse full repositories to resolve dependency chains automatically.

sudo dnf install nginx # RHEL / Rocky package setup
sudo apt update && sudo apt install nginx # Debian / Ubuntu workflow
sudo dnf clean all # Flush package metadata cache for troubleshooting

11. Text Processing Pipelines

Isolate and process text logs with core system tools:

  • grep: filter lines by pattern (e.g., grep -i error /var/log/nginx/error.log).
  • sed: edit streams non-interactively (e.g., sed 's/error/ERROR/g' app.log).
  • awk: print and compute fields (e.g., awk '{print $1,$3}' /etc/passwd).
  • cut: extract fields by delimiter (e.g., cut -d: -f1 /etc/passwd).

Commands Covered in This Chapter

  • dnf / apt / rpm — install, query, and update packages
  • grep — search text by pattern
  • sed — edit text streams
  • awk — process fields and reports
  • cut — extract fields from delimited text
  • sort / uniq — sort lines and drop duplicates
  • wc — count lines, words, and bytes
  • tr — translate or delete characters
  • xargs — build commands from stdin