Skip to content

Repository_management

This chapter covers managing software repositories for different Linux distributions.


Repository Types
+------------------------------------------------------------------+
| |
| Main/Base Repository |
| +------------------------------------------------------------+ |
| | Core packages supported by distribution | |
| +------------------------------------------------------------+ |
| |
| Updates Repository |
| +------------------------------------------------------------+ |
| | Security updates and bug fixes | |
| +------------------------------------------------------------+ |
| |
| Third-Party Repositories |
| +------------------------------------------------------------+ |
| | Vendor-specific (nginx, docker, nodejs) | |
| | Community (EPEL, AUR, Community) | |
| +------------------------------------------------------------+ |
| |
| Testing/Unstable |
| +------------------------------------------------------------+ |
| | Pre-release packages | |
| +------------------------------------------------------------+ |
| |
+------------------------------------------------------------------+

/etc/pacman.conf
[core]
Include = /etc/pacman.d/mirrorlist
[extra]
Include = /etc/pacman.d/mirrorlist
[multilib]
Include = /etc/pacman.d/mirrorlist
[community]
Include = /etc/pacman.d/mirrorlist
Terminal window
# Using yay (AUR helper)
yay -S package_name
# Manual AUR build
git clone https://aur.archlinux.org/package_name.git
cd package_name
makepkg -si
# AUR utilities
yay -Syu --aur # Upgrade AUR packages
yay -Qm # List explicitly installed AUR packages
Terminal window
# Create repo directory
sudo mkdir /opt/packages
sudo cp *.pkg.tar.zst /opt/packages/
# Create database
cd /opt/packages
repo-add custom.db.tar.gz *.pkg.tar.zst
# Add to pacman.conf
[custom]
Server = file:///opt/packages

Terminal window
# main - Free software, supported by Debian
# contrib - Free software, depends on non-free
# non-free - Non-free software
# restricted - Device drivers
# universe - Community-maintained packages
# Debian release categories
# stable - Current stable release
# testing - Testing distribution
# unstable - Rolling development (sid)
# experimental - Pre-release testing
Terminal window
# Add repository (Ubuntu)
sudo add-apt-repository ppa:nginx/stable
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu focal main restricted"
# Add repository (Debian)
echo "deb http://deb.debian.org/debian bookworm main" | sudo tee /etc/apt/sources.list.d/bookworm.list
sudo apt update
/etc/apt/preferences
Package: *
Pin: release a=stable
Pin-Priority: 900
Package: *
Pin: release a=testing
Pin-Priority: 100

EPEL (Extra Packages for Enterprise Linux)

Section titled “EPEL (Extra Packages for Enterprise Linux)”
Terminal window
# Install EPEL
sudo dnf install epel-release
sudo dnf update
# EPEL configuration
cat /etc/yum.repos.d/epel.repo
Terminal window
# Nginx
sudo yum-config-manager --add-repo https://nginx.org/packages/mainline/rhel/8/x86_64/
# Docker
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# PostgreSQL
sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Terminal window
# Register system
sudo subscription-manager register --username USER --password PASS --auto-attach
# List available repos
sudo subscription-manager repos --list
# Enable/disable repos
sudo subscription-manager repos --enable rhel-8-for-x86_64-baseos-rpms
sudo subscription-manager repos --disable rhel-8-for-x86_64-baseos-rpms

Terminal window
# Arch Linux - rankmirrors
sudo pacman-mirrors --fasttrack
# Or manually rank
sudo pacman-mirrors -i -c United_States
# Debian
# Install netselect-apt
sudo apt install netselect-apt
sudo netselect -v -s 1 -t 20 ftp.de.debian.org debian.org
Terminal window
# /etc/pacman.d/mirrorlist - Arch example
Server = https://mirror.us.ArchLinux.org/$repo/os/$arch
Server = https://mirrors.kernel.org/archlinux/$repo/os/$arch
Server = https://mirror.0xsystems.com/archlinux/$repo/os/$arch

Terminal window
# Arch - refresh keys
sudo pacman-key --refresh-keys
# Debian
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys GPG_KEY
sudo apt-key del KEYID
# RHEL
sudo rpm --import /path/to/RPM-GPG-KEY
Terminal window
# Verify package signature
rpm -K package.rpm
dpkg-sig --verify package.deb
# Import key before adding repo
gpg --keyserver keyserver.ubuntu.com --recv-keys GPG_KEY
gpg --export GPG_KEY | sudo apt-key add -

/etc/apt/apt.conf.d/90http-proxy
# apt-cacher-ng
sudo apt install apt-cacher-ng
# Configure clients
Acquire::http::Proxy "http://server:3142";
Terminal window
# Clean cache
sudo dnf clean all
# Keep cache for offline use
sudo dnf cache --optimize

Terminal window
# Basic rsync for local mirror
rsync -avSH --delete \
rsync://rsync.archlinux.org/ftp_tls \
/path/to/local/mirror/
# Schedule with cron
# /etc/cron.d/mirror-sync
0 2 * * * rsync -aSH --delete rsync://... /path/to/mirror/

In this chapter, you learned:

  • ✅ Repository types and concepts
  • ✅ Arch Linux AUR and custom repos
  • ✅ Debian/Ubuntu repository management
  • ✅ RHEL/CentOS repositories and EPEL
  • ✅ Mirror management
  • ✅ Repository security (GPG keys)

Chapter 31: Linux Security Basics - SELinux, AppArmor


Last Updated: February 2026