Linux Package Management: RPM, YUM, DNF and Source Compilation
This guide explains how to manage Linux software packages using RPM, YUM, DNF and manual source compilation, covering preparation steps, repository configuration, common commands, and practical examples with full command‑line snippets.
Linux Package Management
The article introduces four main ways to manage software on Linux: RPM packages, YUM, DNF and building from source.
RPM package management
YUM package management
DNF package management
Source compilation and installation
Preparation
Mount the ISO image to the system.
[root@myserver dev]# mount /dev/sr0 /mnt/
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@myserver dev]# df -h
Filesystem Size Used Avail Use% Mounted on
... (output omitted for brevity) ...RPM Package Management
Windows uses .exe , macOS uses .dmg , and Linux uses .rpm . RPM is convenient for standalone applications but becomes cumbersome when many dependencies are required.
Common RPM commands:
rpm -qa | grep xz – list installed packages matching a pattern
rpm -ivh xxx.rpm – install a package
rpm -e xxx – remove a package
rpm -Uvh xxx.rpm – upgrade a package
cd /mnt/BaseOS/Packages
## Check if the package is already installed
[root@myserver Packages]# rpm -qa | grep xz
xz-libs-5.2.4-3.el8.x86_64
xz-5.2.4-3.el8.x86_64
## Find the RPM files
[root@myserver Packages]# ls | grep xz
xz-5.2.4-3.el8.x86_64.rpm
xz-devel-5.2.4-3.el8.i686.rpm
...
## Install
[root@myserver Packages]# rpm -ivh xz-devel-5.2.4-3.el8.x86_64.rpm
Verifying... [100%]
Preparing... [100%]
Updating / installing...
1:xz-devel-5.2.4-3.el8 [100%]
## Verify installation
[root@myserver Packages]# rpm -qa | grep xz
xz-libs-5.2.4-3.el8.x86_64
xz-5.2.4-3.el8.x86_64
xz-devel-5.2.4-3.el8.x86_64
## Remove
[root@myserver Packages]# rpm -e xz-devel-5.2.4-3.el8.x86_64YUM Package Management
YUM uses repository files ( .repo ) located in /etc/yum.repos.d/ . A typical repo entry includes name, baseurl, gpgcheck, enabled and gpgkey.
Key YUM commands:
yum remove xz-devel – uninstall a package
yum -y install xz-devel – install without interactive prompts
yum update xz-devel – update a package
yum clean all – clear cache
Backup existing repo files before making changes:
[root@myserver yum.repos.d]# mkdir bak
[root@myserver yum.repos.d]# mv *.repo bak/Example of a local repo configuration:
[myrepo]
name=My first repo test.
baseurl=file:///mnt/BaseOS/
gpgcheck=0
enabled=1Listing the new repo and installing a package from it:
[root@myserver ~]# yum repolist
repo id repo name
myrepo My first repo test.
[root@myserver ~]# yum install xz*
... (installation output) ...DNF Package Management
DNF (Dandified YUM) is the next‑generation package manager for Fedora and newer RHEL‑based distributions. It is faster and uses less memory than YUM.
Common DNF commands:
dnf list installed – list installed packages
dnf search pkg – search for a package
dnf install pkg – install a package
dnf reinstall pkg – reinstall a package
dnf download pkg – download the RPM without installing
dnf check-update – check for updates
dnf update – apply updates
dnf repolist all – list all configured repositories
dnf remove pkg – uninstall a package
dnf clean all – clean the cache
Source Compilation and Installation
When a pre‑built package is unavailable, software can be built from source.
Typical steps:
Download the source archive (e.g., with wget ).
Extract the archive using tar (e.g., tar zxf file.tar.gz -C /usr/local ).
Run ./configure to generate a Makefile.
Compile with make .
Install with make install .
Example: building zlib from source.
# Download
[root@myserver ~]# wget http://zlib.net/zlib-1.2.11.tar.gz
# Extract
[root@myserver ~]# tar zxf zlib-1.2.11.tar.gz -C /usr/local/
# Configure
[root@myserver zlib-1.2.11]# ./configure
... (configuration output) ...
# Build and install
[root@myserver zlib-1.2.11]# make
[root@myserver zlib-1.2.11]# make install
... (installation output) ...Before compiling, ensure development tools are installed:
yum -y install gcc automake autoconf libtool make
yum install gcc gcc-c++The article concludes with a reminder to follow the official documentation for specific software (e.g., Nginx) and to install required compilers.
DevOps Cloud Academy
Exploring industry DevOps practices and technical expertise.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.