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
| Format | Used By | Description |
|---|---|---|
| RPM | RHEL, Rocky, AlmaLinux, Fedora | Red Hat Package Manager format. |
| DEB | Debian, Ubuntu | Debian package format. |
| Source Code | All | Compiled manually. |
| Flatpak | Multiple distributions | Sandboxed desktop packages. |
| Snap | Ubuntu and others | Universal package format. |
| AppImage | Multiple distributions | Portable application package. |
5. Package Managers by Distribution
| Distribution | Package Manager |
|---|---|
| RHEL / Rocky / AlmaLinux | rpm, yum, dnf |
| Fedora | dnf |
| Debian / Ubuntu | apt, 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)
- Identify your Linux distribution and kernel version.
- Determine whether your system uses RPM or APT binaries.
- 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 packagesgrep— search text by patternsed— edit text streamsawk— process fields and reportscut— extract fields from delimited textsort/uniq— sort lines and drop duplicateswc— count lines, words, and bytestr— translate or delete charactersxargs— build commands from stdin