Software management in Linux environments involves handling two primary formats: uncompiled source code (tabralls) and pre-compiled binary packages. The management tools differ across distributions, with RedHat-based systems (CentOS, Fedora) utilizing the RPM ecosystem, while Debian-based systems (Ubuntu) use DPKG and APT.
1. Understanding RPM Package Structure
RPM (Red Hat Package Manager) files follow a specific naming convention that indicates the software version and target architecture. For example, a file named app-server-2.4.10-5.el7.x86_64.rpm breaks down as follows:
- app-server: The software package name.
- 2.4.10: The software version.
- 5.el7: The release version and distribution (Enterprise Linux 7).
- x86_64: The hardware architecture (64-bit). Common architectures include i386, x86_64, and noarch (platform independent).
To identify your current system's architecture and version details, you can use the following commands:
# Check hardware architecture
uname -m
# Check OS distribution details
cat /etc/redhat-release
2. Manual Package Management with RPM
The rpm utility allows for direct interaction with packages but requires the administrator to resolve dependencies manually.
Installation and Removal
# Install a package with verbose progress tracking
rpm -ivh application-package.rpm
# Forced installation (if files are corrupted)
rpm -ivh --force application-package.rpm
# Uninstall a package
rpm -e application-package
# Remove while ignoring dependency errors (not recommended)
rpm -e application-package --nodeps
Querying the RPM Database
# Check if a specific package is installed
rpm -q nginx
# List all installed packages and filter for a keyword
rpm -qa | grep python
# List all files installed by a specific package
rpm -ql nginx
# Find which package a specific file belongs to
rpm -qf /usr/sbin/nginx
# View detailed metadata about an installed package
rpm -qi nginx
# List configuration files associated with a package
rpm -qc vsftpd
3. Automated Management with YUM
YUM (Yellowdog Updater, Modified) builds upon RPM by automatically calculating and resolving software dependencies using metadata stored in repositories.
Configuring a Local Repository
To use a local source like a mounted ISO or a local directory, create a .repo file in /etc/yum.repos.d/:
[LocalRepo]
name=Local Software Source
baseurl=file:///mnt/cdrom/Packages
enabled=1
gpgcheck=0
Common YUM Operations
# Clear cached metadata and check active repositories
yum clean all
yum repolist
# Install a package and its dependencies
yum -y install mariadb-server
# Update a specific package
yum update bash
# Search for a package that provides a specific command or file
yum provides /usr/bin/htpasswd
# Install a group of related software (e.g., Development Tools)
yum grouplist
yum groupinstall "Development Tools"
Creating Custom Repositories
If you have a collection of standalone RPM files, you can turn their directory into a YUM-compatible repository using createrepo:
# Install the tool
yum install createrepo
# Initialize the repository metadata in the current directory
cd /custom/rpm/dir
createrepo .
4. Working with GPG Signatures
To ensure package integrity, Linux distributions use GPG keys to sign packages. You can import these keys to enable signature verification during installation.
# Import the official distribution key
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
# Enable verification in the repo config
# Edit /etc/yum.repos.d/example.repo:
# gpgcheck=1
# gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
5. Compiling from Source (Tarballs)
Installing from source allows for custom configuratoin and access to the latest software versions not yet packaged by distributions. This typically involves three main steps.
Prerequisites
Ensure a compiler like gcc and necessary headers are installed. Using yum groupinstall "Development Tools" is the standard approach.
The Installation Workflow
# 1. Extract the archive
tar -xzvf web-server-v2.tar.gz
cd web-server-v2
# 2. Configuration: Define installation path and features
./configure --prefix=/usr/local/webserver --enable-so
# 3. Compile and Install
make
make install
After installation, the software can be managed via the binaries located in the specified prefix directory, such as /usr/local/webserver/bin/.