Installing Software from .rpm Packages
Table of Contents
- [Introduction](#introduction) - [Understanding RPM Package Format](#understanding-rpm-package-format) - [RPM Database](#rpm-database) - [Installation Methods](#installation-methods) - [Package Management Tools](#package-management-tools) - [Installation Commands](#installation-commands) - [Verification and Troubleshooting](#verification-and-troubleshooting) - [Best Practices](#best-practices) - [Common Issues and Solutions](#common-issues-and-solutions)Introduction
RPM (Red Hat Package Manager) is a powerful package management system used primarily by Red Hat Enterprise Linux (RHEL), CentOS, Fedora, SUSE, and other Linux distributions. RPM packages contain pre-compiled software along with metadata, dependency information, and installation scripts that make software installation and management straightforward and reliable.
The RPM system provides several key benefits: - Dependency Management: Automatically handles software dependencies - Database Tracking: Maintains a comprehensive database of installed packages - Verification: Allows verification of package integrity and installed files - Rollback Capability: Enables package removal and downgrading - Digital Signatures: Supports package signing for security verification
Understanding RPM Package Format
Package Naming Convention
RPM packages follow a standardized naming convention that provides essential information about the package:
`
package-name-version-release.architecture.rpm
`
| Component | Description | Example | |-----------|-------------|---------| | package-name | The name of the software | firefox | | version | The software version number | 91.0 | | release | The package build number | 1.el8 | | architecture | Target hardware architecture | x86_64, i386, noarch | | extension | Always .rpm | .rpm |
Example Package Names
| Package Name | Breakdown | |--------------|-----------| | firefox-91.0-1.el8.x86_64.rpm | Firefox version 91.0, build 1 for RHEL 8, 64-bit | | vim-8.2.2637-16.el9.x86_64.rpm | Vim editor version 8.2.2637, build 16 for RHEL 9 | | kernel-5.14.0-70.el9.x86_64.rpm | Kernel version 5.14.0, build 70 for RHEL 9 | | python3-requests-2.25.1-1.el8.noarch.rpm | Python requests library, architecture independent |
Package Architecture Types
| Architecture | Description | Usage | |--------------|-------------|-------| | x86_64 | 64-bit Intel/AMD processors | Most modern systems | | i386/i686 | 32-bit Intel processors | Legacy systems | | aarch64 | 64-bit ARM processors | ARM-based systems | | noarch | Architecture independent | Scripts, documentation | | src | Source code packages | Development purposes |
RPM Database
The RPM database is a critical component that tracks all installed packages and their files. Located in /var/lib/rpm/, this database contains:
Database Files
| File | Purpose | |------|---------| | Packages | Main package information database | | Name | Package name index | | Version | Version information index | | Release | Release information index | | Providename | What packages provide | | Requirename | Package dependencies | | Conflictname | Package conflicts | | Obsoletename | Obsoleted packages |
Database Maintenance Commands
`bash
Rebuild the RPM database
rpm --rebuilddbVerify database consistency
rpm --verifydbInitialize a new database
rpm --initdb`Installation Methods
Method 1: Using rpm Command
The rpm command is the low-level tool for package management. It provides direct control over package installation but does not automatically resolve dependencies.
#### Basic Installation Syntax
`bash
rpm [options] package-file.rpm
`
#### Common rpm Options
| Option | Description | Example | |--------|-------------|---------| | -i | Install package | rpm -i package.rpm | | -U | Upgrade package (install if not present) | rpm -U package.rpm | | -F | Freshen package (upgrade only if already installed) | rpm -F package.rpm | | -e | Erase (remove) package | rpm -e package-name | | -q | Query package information | rpm -q package-name | | -v | Verbose output | rpm -iv package.rpm | | -h | Show progress with hash marks | rpm -ivh package.rpm | | --force | Force installation | rpm -ivh --force package.rpm | | --nodeps | Ignore dependencies | rpm -ivh --nodeps package.rpm | | --test | Test installation without actually installing | rpm -ivh --test package.rpm |
Method 2: Using yum/dnf
YUM (Yellowdog Updater Modified) and DNF (Dandified YUM) are high-level package managers that automatically handle dependencies and can install packages from repositories or local files.
#### Installing Local RPM with yum
`bash
RHEL/CentOS 7 and earlier
yum localinstall package.rpmAlternative method
yum install package.rpm`#### Installing Local RPM with dnf
`bash
RHEL/CentOS 8+ and Fedora
dnf localinstall package.rpmAlternative method
dnf install package.rpm`Method 3: Using zypper (SUSE)
For SUSE-based distributions, zypper is the preferred package manager:
`bash
Install local RPM package
zypper install package.rpmInstall with dependency resolution
zypper install --allow-unsigned-rpm package.rpm`Package Management Tools
rpm Command Reference
#### Installation Commands
`bash
Install a new package
rpm -ivh package.rpmInstall with verbose output and progress
rpm -ivh --progress package.rpmInstall multiple packages
rpm -ivh package1.rpm package2.rpm package3.rpmUpgrade existing package or install if not present
rpm -Uvh package.rpmFreshen only if package is already installed
rpm -Fvh package.rpmForce installation (overwrite files)
rpm -ivh --force package.rpmInstall ignoring dependencies (not recommended)
rpm -ivh --nodeps package.rpmTest installation without actually installing
rpm -ivh --test package.rpm`#### Query Commands
`bash
List all installed packages
rpm -qaQuery specific package
rpm -q package-nameShow package information
rpm -qi package-nameList files in package
rpm -ql package-nameShow package dependencies
rpm -qR package-nameFind which package owns a file
rpm -qf /path/to/fileQuery package file before installation
rpm -qip package.rpmList files in package file
rpm -qlp package.rpm`#### Verification Commands
`bash
Verify all installed packages
rpm -VaVerify specific package
rpm -V package-nameVerify package file
rpm -Vp package.rpmCheck package signatures
rpm --checksig package.rpm`#### Removal Commands
`bash
Remove package
rpm -e package-nameRemove with verbose output
rpm -ev package-nameForce removal (ignore dependencies)
rpm -e --nodeps package-nameTest removal without actually removing
rpm -e --test package-name`Advanced rpm Options
| Option | Description | Use Case | |--------|-------------|----------| | --prefix PATH | Relocate package to different path | Custom installation locations | | --excludedocs | Don't install documentation | Minimal installations | | --noscripts | Don't execute pre/post install scripts | Troubleshooting | | --oldpackage | Allow downgrade to older version | Rollback scenarios | | --replacefiles | Replace files owned by other packages | Conflict resolution | | --replacepkgs | Reinstall already installed package | Package repair |
Installation Commands
Step-by-Step Installation Process
#### 1. Download Package Verification
Before installation, verify the package integrity and authenticity:
`bash
Check package signature
rpm --checksig package.rpmExpected output for valid package:
package.rpm: rsa sha1 (md5) pgp md5 OK
Detailed signature check
rpm -Kv package.rpm`#### 2. Dependency Analysis
Check package dependencies before installation:
`bash
Show package requirements
rpm -qpR package.rpmShow what the package provides
rpm -qpP package.rpmTest installation to check for conflicts
rpm -ivh --test package.rpm`#### 3. Installation Execution
`bash
Standard installation with progress
rpm -ivh package.rpmInstallation with detailed output
rpm -ivh --verbose package.rpmInstallation from URL
rpm -ivh http://example.com/package.rpmInstallation from multiple sources
rpm -ivh package1.rpm package2.rpm http://example.com/package3.rpm`Batch Installation Examples
#### Installing Multiple Related Packages
`bash
Install all RPM files in current directory
rpm -ivh *.rpmInstall specific pattern of packages
rpm -ivh mysql-*.rpmInstall from different directories
rpm -ivh /path/to/packages/.rpm /other/path/.rpm`#### Installation with Logging
`bash
Install with detailed logging
rpm -ivh --verbose package.rpm 2>&1 | tee install.logInstall with only error logging
rpm -ivh package.rpm 2> error.log`Upgrade and Freshen Operations
#### Upgrade vs Install
| Operation | Command | Behavior | |-----------|---------|----------| | Install | rpm -ivh | Installs new package, keeps old versions | | Upgrade | rpm -Uvh | Installs new package, removes old version | | Freshen | rpm -Fvh | Upgrades only if package already installed |
#### Upgrade Examples
`bash
Upgrade single package
rpm -Uvh newer-package.rpmUpgrade all packages in directory
rpm -Uvh *.rpmUpgrade with backup of replaced files
rpm -Uvh --backup package.rpmUpgrade kernel (special case - use install)
rpm -ivh kernel-new-version.rpm`Working with Package Groups
`bash
Install development tools group
yum groupinstall "Development Tools"List available groups
yum grouplistInstall specific group with dnf
dnf group install "Development Tools"`Verification and Troubleshooting
Package Verification Process
RPM provides comprehensive verification capabilities to ensure package integrity and proper installation.
#### Verification Attributes
When verifying packages, RPM checks these attributes:
| Attribute | Symbol | Description | |-----------|---------|-------------| | Size | S | File size differs | | Mode | M | File permissions differ | | MD5 checksum | 5 | File content differs | | Device | D | Device number differs | | Link | L | Symbolic link differs | | User | U | File owner differs | | Group | G | File group differs | | Time | T | File modification time differs |
#### Verification Commands and Examples
`bash
Verify all installed packages
rpm -VaVerify specific package
rpm -V opensshExample output:
S.5....T. /usr/bin/ssh
This indicates size, checksum, and time differences
Verify configuration files only
rpm -V --configfiles opensshVerify without checking file modification times
rpm -V --nofiledigest openssh`Troubleshooting Common Issues
#### Dependency Problems
`bash
Problem: Missing dependencies
Error: Failed dependencies: libssl.so.1.1 is needed by package
Solution 1: Install dependencies manually
yum install openssl-libsSolution 2: Use yum/dnf to handle dependencies
yum localinstall package.rpmSolution 3: Force installation (not recommended)
rpm -ivh --nodeps package.rpm`#### File Conflicts
`bash
Problem: File conflicts during installation
Error: file /usr/bin/program conflicts between attempted installs
Solution 1: Check which packages provide the file
rpm -qf /usr/bin/programSolution 2: Force replacement
rpm -ivh --replacefiles package.rpmSolution 3: Remove conflicting package first
rpm -e conflicting-package rpm -ivh new-package.rpm`#### Database Corruption
`bash
Problem: RPM database corruption
Error: rpmdb: damaged header instance
Solution: Rebuild database
cd /var/lib/rpm rm -f __db* rpm --rebuilddbVerify database after rebuild
rpm --verifydb`Package Integrity Checking
#### GPG Key Management
`bash
Import GPG keys
rpm --import RPM-GPG-KEY-redhat-releaseList imported keys
rpm -q gpg-pubkey --qf '%{name}-%{version}-%{release} --> %{summary}\n'Verify package signature
rpm --checksig package.rpm`#### File System Verification
`bash
Check for modified configuration files
rpm -Va | grep '^..5'Check for missing files
rpm -Va | grep 'missing'Verify specific file types
rpm -Va --configfiles # Configuration files only rpm -Va --docfiles # Documentation files only`Best Practices
Pre-Installation Checklist
1. System Compatibility Check
`bash
# Check system architecture
uname -m
# Check OS version
cat /etc/redhat-release
# Verify package compatibility
rpm -qp --requires package.rpm
`
2. Backup Critical Data
`bash
# Backup configuration files
tar -czf config-backup.tar.gz /etc/
# Create system snapshot (if using LVM)
lvcreate -L1G -s -n backup-snapshot /dev/vg/root
`
3. Free Space Verification
`bash
# Check available disk space
df -h
# Check package installation size
rpm -qp --queryformat '%{SIZE}\n' package.rpm
`
Installation Best Practices
#### Security Considerations
| Practice | Command | Rationale |
|----------|---------|-----------|
| Verify signatures | rpm --checksig package.rpm | Ensures package authenticity |
| Check source | Download from official repositories | Prevents malware installation |
| Review dependencies | rpm -qpR package.rpm | Understand system changes |
| Test installation | rpm -ivh --test package.rpm | Identify issues before installation |
#### System Maintenance
`bash
Regular database maintenance
rpm --rebuilddbClean up old kernel packages
package-cleanup --oldkernels --count=2Verify system integrity monthly
rpm -Va > /var/log/rpm-verify.log`Repository Management
#### Adding Third-Party Repositories
`bash
Add EPEL repository
yum install epel-releaseAdd custom repository
cat > /etc/yum.repos.d/custom.repo << EOF [custom] name=Custom Repository baseurl=http://example.com/repo/ enabled=1 gpgcheck=1 gpgkey=http://example.com/RPM-GPG-KEY EOF`#### Repository Priority
`bash
Install yum-plugin-priorities
yum install yum-plugin-prioritiesSet repository priorities in .repo files
priority=1 (highest) to priority=99 (lowest)
`Common Issues and Solutions
Installation Failures
#### Issue 1: Insufficient Privileges
`bash
Problem: Permission denied errors
Solution: Use sudo or run as root
sudo rpm -ivh package.rpmOr switch to root user
su - rpm -ivh package.rpm`#### Issue 2: Package Already Installed
`bash
Problem: package is already installed
Error: package-1.0-1 is already installed
Solution 1: Upgrade instead
rpm -Uvh newer-package.rpmSolution 2: Reinstall
rpm -ivh --replacepkgs package.rpmSolution 3: Force installation
rpm -ivh --force package.rpm`#### Issue 3: Conflicting Files
`bash
Problem: File conflicts between packages
Error: file /usr/bin/app from install of new-package conflicts with file from package old-package
Solution 1: Remove conflicting package
rpm -e old-package rpm -ivh new-package.rpmSolution 2: Force file replacement
rpm -ivh --replacefiles new-package.rpm`Performance Optimization
#### Database Optimization
`bash
Optimize RPM database
rpm --rebuilddbClean temporary files
rm -rf /var/tmp/rpm-*Verify database integrity
rpm --verifydb`#### Installation Speed Improvement
`bash
Use local repositories when possible
createrepo /path/to/local/packagesEnable parallel downloads (dnf)
echo "max_parallel_downloads=10" >> /etc/dnf/dnf.confUse faster mirrors
yum-config-manager --enable fastestmirror`Rollback and Recovery
#### Package Rollback Strategies
`bash
Downgrade package (if older version available)
yum downgrade package-nameRemove problematic package
rpm -e package-nameRestore from backup
tar -xzf config-backup.tar.gz -C /`#### System Recovery
`bash
Boot from rescue mode if system is unbootable
Mount root filesystem
mount /dev/sda1 /mntChroot into system
chroot /mntFix RPM database
rpm --rebuilddbVerify and fix packages
rpm -Va --root /mnt`Monitoring and Logging
#### Installation Logging
`bash
Enable detailed RPM logging
echo "%_log_file /var/log/rpm.log" >> ~/.rpmmacrosMonitor installation progress
tail -f /var/log/rpm.logArchive installation logs
logrotate /etc/logrotate.d/rpm`#### System Monitoring
`bash
Monitor package changes
rpm -qa --last | head -20Check for security updates
yum updateinfo list securityMonitor system resources during installation
iostat -x 1 top -p $(pgrep rpm)`This comprehensive guide covers all aspects of installing software from RPM packages, from basic concepts to advanced troubleshooting techniques. The information provided enables both novice and experienced users to effectively manage RPM packages in their Linux environments while following security best practices and maintaining system integrity.