๐Ÿ“ฆ Day 3 of #150DaysOfDevOps โ€“ Introduction to Linux Package Management

Vignesh MVignesh M
4 min read

Package management is at the heart of Linux system administration. Whether you're installing software, updating dependencies, or maintaining a clean environment, package managers make life easier for DevOps professionals.

In this blog, we'll cover key package managers used in Debian-based and RedHat-based Linux distributions:

๐Ÿค” What is a Package?

A package is a compressed archive that contains all the files needed for a software to run: binaries, libraries, config files, metadata, and more.

For example:

  • gimp.deb โ†’ for Debian-based systems

  • firefox.rpm โ†’ for RedHat-based systems

โš™๏ธ Why Package Managers?

With hundreds of Linux distributions and diverse libraries/tools, direct installation of packages often fails due to dependency hell. Package managers:

  • Automate dependency resolution

  • Ensure system compatibility

  • Streamline software installation and upgrades

๐Ÿง Package Managers by Distribution

DistributionPackage FormatLow-Level ToolHigh-Level Tool
Ubuntu / Debian.debdpkgapt, apt-get
RHEL / CentOS / Fedora.rpmrpmyum, dnf

๐Ÿ”ด RPM (Red Hat Package Manager)

RPM is a low-level tool used in RedHat-based distributions.

Common Commands:

# Install a package
sudo rpm -ivh package.rpm

# Remove a package
sudo rpm -e package-name

# Query installed packages
rpm -qa | grep wget

โŒ Limitation:

Does not resolve dependencies on its own.

๐ŸŸ  YUM (Yellowdog Updater Modified)

YUM is a high-level package manager that wraps RPM and handles dependencies automatically.

YUM Commands:

# Install
sudo yum install httpd -y

# Remove
sudo yum remove httpd

# Update one package
sudo yum update telnet

# Update all packages
sudo yum update

# List repositories
yum repolist

# Check package for a command
yum provides scp

Repository Location:

/etc/yum.repos.d/*.repo

๐ŸŸข DPKG (Debian Package Manager)

DPKG is the low-level tool for .deb packages.

Common Commands:

# Install a package
sudo dpkg -i package.deb

# Remove a package
sudo dpkg -r package-name

# List installed packages
dpkg -l

# Show package status
dpkg -s package-name

โŒ Limitation:

No dependency management โ€” installs fail if dependencies are missing.

๐Ÿ”ต APT (Advanced Package Tool)

APT is a high-level tool for Debian-based systems that resolves dependencies automatically.

APT Commands:

# Update repo index
sudo apt update

# Upgrade all packages
sudo apt upgrade

# Install a package
sudo apt install gimp

# Remove a package
sudo apt remove gimp

# Search a package
apt search telnet

Repository File:

/etc/apt/sources.list

โš”๏ธ APT vs APT-GET

Featureaptapt-get
User-friendlyโœ… YesโŒ No (minimal output)
Default in modern distrosโœ… Installedโœ… Installed
Progress barโœ… YesโŒ No
Command simplicityโœ… Yes (apt search)โŒ Uses apt-cache

๐Ÿ” Final Thoughts

  • Use RPM + YUM on RHEL/CentOS

  • Use DPKG + APT on Ubuntu/Debian

  • Prefer high-level tools (yum, apt) for easier dependency handling

  • Know the config files: /etc/yum.repos.d/, /etc/apt/sources.list

๐Ÿง  Advanced Tips

โœ… Using yum history to track package operations

# View YUM transaction history
yum history

# Undo a transaction (e.g., ID 15)
yum history undo 15

โœ… Cleaning up unused packages and cache

# Remove old/unused packages
sudo yum autoremove

# Clean up YUM cache
sudo yum clean all

# Clean up APT cache
sudo apt autoremove
sudo apt clean

โœ… Simulating package installation (dry-run)

# Simulate with APT (dry-run)
sudo apt install <package-name> --dry-run

# With YUM (dry-run equivalent using --assumeno)
sudo yum install <package-name> --assumeno

โœ… Lock a package version (APT-based)

# Prevent a package from upgrading
sudo apt-mark hold <package-name>

# Remove the lock
sudo apt-mark unhold <package-name>

โœ… Find which package owns a file

# RPM-based
rpm -qf /bin/ls

# APT-based
dpkg -S /bin/ls
0
Subscribe to my newsletter

Read articles from Vignesh M directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Vignesh M
Vignesh M

๐Ÿ› ๏ธ DevOps Engineer in Progress | ๐Ÿš€ Documenting my #150DaysOfDevOps journey | ๐Ÿ’ก Passionate about Linux, Cloud & Automation | ๐ŸŒ Sharing what I learn every day