Fading Coder

One Final Commit for the Last Sprint

Home > Notes > Content

Installing Software on Linux Systems: RPM, YUM, and Source Compilation

Notes 2

Linux systems primari support three methods for installing software: RPM, YUM, and source compilation.

Core Concepts and Differences

The table below outlines the key distinctions between these installation approaches:

Feature RPM Installation YUM Installation Source Compilation
Nature Installs precompiled .rpm binaries Automates RPM-based package management Compiles source code manually
Dependency Handling Manual resolution Automatic dependancy fetching Manual dependency setup
Installation Path Fixed (FHS compliant) Fixed (same as RPM) Fully customizable
Flexibility Low (limited to prebuilt options) Low (RPM constraints) High (customizable build options)
Ease of Use Moderate (manual deps) High (fully automated) Low (requires compilation knowledge)
Maintainability Moderate (manual updates/uninstalls) High (automatic upgrades/removals) Low (no centralized control)
Supported Distributions CentOS/RHEL/Fedora CentOS/RHEL/Fedora All Linux distributions

Detailed Methods and Examples

1. RPM Package Installation

Overview:

RPM packages are binary files specific to Red Hat-based systems. These packages contain precompiled executables and metadata. However, they do not automatically resolve dependencies, which is a major limitation.

Commmon Commands:

# Install an RPM file locally
sudo rpm -ivh nginx-1.24.0-1.el7.x86_64.rpm

# Remove an installed RPM package
sudo rpm -e nginx

# List all installed packages containing 'nginx'
rpm -qa | grep nginx

2. YUM Package Management

Overview:

YUM is a high-level package manager built on top of RPM. It automates the process of resolving dependencies and downloading packages from configured repositories.

Common Commands:

# Install a package with automatic dependency handling
sudo yum install -y nginx

# Update a specific package
sudo yum update -y nginx

# Remove a package
sudo yum remove -y nginx

# List available versions of a package
yum list | grep nginx

3. Source Code Compilation

Overview:

Source compilation involves downloading the source code archive, configuring the build environment, compiling it into executable binaries, and then installing the result. This method allows full customization of features and installation paths.

General Compilation Steps (for Nginx):

# Install necessary development tools and libraries
sudo yum install -y gcc pcre-devel zlib-devel openssl-devel

# Download and extract source
wget https://nginx.org/download/nginx-1.24.0.tar.gz
tar -zxvf nginx-1.24.0.tar.gz
cd nginx-1.24.0

# Configure compilation options
./configure --prefix=/usr/local/nginx \
            --with-http_ssl_module \
            --without-http_gzip_module

# Compile with parallel jobs
make -j4

# Install compiled binaries
sudo make install

# Start the service
/usr/local/nginx/sbin/nginx

Comparison Table

Method Pros Cons
RPM Fast, offline compatible, simple Manual dependency handling, fixed paths
YUM Auto dependency, easy maintenance Requires network, limited customization
Source Fully customizable, optimized builds Complex steps, error-prone, hard to maintain

Recommendations

  1. Prefer YUM: For standard software like MySQL, Nginx, Docker, use YUM if available – it's reliable and easy to manage.
  2. Use RPM when: Working offline or with single RPM files; ensure dependencies are resolved manually.
  3. Choose source compilation for: Specialized setups requiring custom paths, feature toggles, or when no prebuilt binaries exist.

Additional Notes

  • Relationship Between YUM and RPM: YUM is essentially an enhanced version of RPM that adds automatic dependency resolution and repository access.
  • Compilation Prerequisites: Always install compilers (gcc) and corresponding development headers (e.g., pcre-devel) before attempting to compile.

Different Linux distributions utilize different package formats and managers:

Distribution Family Package Format Base Command High-Level Manager Example Systems
RedHat/CentOS/RHEL/Fedora .rpm rpm yum / dnf CentOS 7, RHEL 8/9
Debian/Ubuntu/Linux Mint .deb dpkg apt Ubuntu 18.04/20.04/22.04
SUSE/SLES/openSUSE .rpm rpm zypper SUSE Enterprise Server
Arch/Manjaro .pkg.tar.zst pacman pacman Arch Linux, Manjaro
Alpine .apk apk apk Alpine 3.x

Package Management Commands Summary

Action RedHat/CentOS (yum/dnf) Debian/Ubuntu (apt) SUSE (zypper) Arch (pacman) Alpine (apk)
Install package yum install nginx apt install nginx zypper in nginx pacman -S nginx apk add nginx
Remove package yum remove nginx apt remove nginx zypper rm nginx pacman -R nginx apk del nginx
Refresh package cache yum makecache apt update zypper ref pacman -Sy apk update
Upgrade all packages yum update apt upgrade zypper up pacman -Syu apk upgrade
Search for package yum search nginx apt search nginx zypper se nginx pacman -Ss nginx apk search nginx
List installed packages yum list installed apt list --installed zypper pa -i pacman -Q apk info
Check package status `yum list installed grep [name]` `apt list --installed grep [name]` zypper se -i [name]

Summary

  1. Ease of Use: YUM > RPM > Source Compilation
  2. Customization Level: Source Compilation > RPM > YUM
  3. Best Practices: Use YUM for daily tasks, RPM for offline environments, and source compilation for advanced configurations.
  4. Core Relationships: YUM builds upon RPM for automation; source compilation operates independently of prebuilt packages, offering maximum flexibility at the cost of complexity.

Related Articles

Designing Alertmanager Templates for Prometheus Notifications

How to craft Alertmanager templates to format alert messages, improving clarity and presentation. Alertmanager uses Go’s text/template engine with additional helper functions. Alerting rules referenc...

Deploying a Maven Web Application to Tomcat 9 Using the Tomcat Manager

Tomcat 9 does not provide a dedicated Maven plugin. The Tomcat Manager interface, however, is backward-compatible, so the Tomcat 7 Maven Plugin can be used to deploy to Tomcat 9. This guide shows two...

Skipping Errors in MySQL Asynchronous Replication

When a replica halts because the SQL thread encounters an error, you can resume replication by skipping the problematic event(s). Two common approaches are available. Methods to Skip Errors 1) Skip a...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.