Repositories (repos) are centralized storage locations containing software packages for Linux distributions. They enable secure, automated software installation and updates through package managers like apt, yum, or dnf.
Key Concepts
- Repository: Server hosting software packages
- Package Manager: Tool to install/update software
- Sources List: File defining available repos
- GPG Keys: Digital signatures for security
- Mirror: Alternative server with same content
- PPA: Personal Package Archives (Ubuntu)
Command Syntax
Debian/Ubuntu (APT)
apt [options] command [package]
apt-get [options] command [package]
RHEL/CentOS/Fedora
yum [options] command [package]
dnf [options] command [package]
Common Options
APT Commands
update - Refresh package lists
upgrade - Install available updates
install - Install specific package
search - Find packages
list - Show available/installed packages
YUM/DNF Commands
update - Update all packages
install - Install package
search - Search for packages
list - List packages
repolist - Show configured repositories
Practical Examples
Example 1: Update Package Lists
|
|
Refreshes local package database with latest versions from repositories
Example 2: Search for Package
|
|
Finds packages matching “nginx” in repos
Example 3: Install Package
|
|
Downloads and installs nginx web server
Example 4: List Repositories
|
|
Shows currently configured repositories
Example 5: Add Repository
|
|
Adds new software repository
Repository Configuration Files
Debian/Ubuntu
/etc/apt/sources.list- Main sources file/etc/apt/sources.list.d/- Additional repos/etc/apt/trusted.gpg.d/- GPG keys
RHEL/CentOS/Fedora
/etc/yum.repos.d/- Repository configs/etc/pki/rpm-gpg/- GPG keys
Use Cases
- Installing software not in default repos
- Getting newer versions of packages
- Adding specialized software collections
- Enterprise software repositories
- Development tools and libraries
- Security updates and patches
Related Commands
apt-key - Manage APT repository keys
add-apt-repository - Add Ubuntu PPAs
yum-config-manager - Manage YUM repos
rpm --import - Import GPG keys for RPM
gpg - Verify package signatures
Tips & Troubleshooting
Common Issues
- GPG key errors: Import missing keys
|
|
- Repository not found: Check URL and internet connection
- Package conflicts: Use
apt --fix-brokenoryum clean all
Best Practices
- Always update package lists before installing
- Use official repositories when possible
- Verify GPG signatures for security
- Keep repository list backed up
- Remove unused repositories to reduce overhead
Security Notes
- Only add trusted repositories
- Verify GPG keys before importing
- Avoid mixing repositories from different distributions
- Regular security updates are critical
Repository Priority
Some systems allow setting repository priorities to control which repo provides packages when multiple sources exist.
|
|