Operations 9 min read

Master Linux Package Management: yum, apt, dpkg, and Source Compilation

This guide walks you through Linux package management fundamentals, covering yum and apt/apt‑get commands, dpkg/rpm operations, and a step‑by‑step example of compiling and installing software from source such as Nginx, while highlighting convenience, customizability, and permission considerations.

Raymond Ops
Raymond Ops
Raymond Ops
Master Linux Package Management: yum, apt, dpkg, and Source Compilation

yum (RPM‑based distributions)

Update repository cache : sudo yum clean all && sudo yum makecache Install a package : sudo yum install <package_name>[-<version>] Upgrade a package : sudo yum upgrade <package_name> (upgrade all: sudo yum update)

Remove a package : sudo yum remove <package_name> Downgrade a package : sudo yum downgrade <package_name>-<version> Search for a package : yum search <package_name> List installed packages : yum list installed [<package_name>] Show available versions : yum list <package_name> --showduplicates Lock a version : sudo yum versionlock add <package_name>[-version] Unlock a version : sudo yum versionlock delete <package_name> Clear all locks : sudo yum versionlock clear List locked packages : yum versionlock list Tip: To use version locking, install the plugin first: sudo yum install yum-plugin-versionlock.

apt / apt‑get (Debian‑based distributions)

Edit sources : sudo apt edit-sources [<source_name>] Update repository cache : sudo apt update or sudo apt‑get update Install a package : sudo apt install <package_name>[=<version>] Upgrade a package : sudo apt upgrade <package_name> Remove a package : sudo apt remove <package_name> Purge configuration files : sudo apt purge <package_name> List installed packages : apt list [<package_name>] -i Search for a package : apt‑cache search <package_name> --names-only Show package details : apt‑cache show <package_name> Fix broken dependencies : sudo apt‑get -f install Auto‑remove unused dependencies : sudo apt‑get autoremove Show version policy : apt‑cache policy <package_name> List all available versions : apt list <package_name> -a or apt‑cache madison <package_name> Hold a package (lock version) : sudo apt‑mark hold <package_name> Unhold a package (unlock) : sudo apt‑mark unhold <package_name> Show held packages :

apt‑mark showhold

dpkg / rpm (low‑level package tools)

Install : sudo dpkg -i <deb_name> [--force-depends] or sudo rpm -ivh <rpm_name> Upgrade : sudo rpm -Uvh <rpm_name> Remove : sudo dpkg -r <deb_name> or sudo rpm -e [--nodeps] <rpm_name> Purge (dpkg only) : sudo dpkg -P --purge <deb_name> List installed packages : dpkg -l <deb_name> or rpm -qa <rpm_name> Show package information : dpkg -s <deb_name> or rpm -qi <rpm_name> List package contents : dpkg -L <deb_name> or rpm -ql <rpm_name> Find owning package of a file : dpkg -S <file_name> or

rpm -qf <file_name>

Compiling and Installing from Source (example: Nginx)

Obtain the source archive

wget https://nginx.org/download/nginx-1.24.0.tar.gz
tar -xzvf nginx-1.24.0.tar.gz
cd nginx-1.24.0

Install build dependencies sudo yum install pcre-devel zlib-devel Configure, compile, and install

./configure --prefix=/usr/local/nginx   # add other options as needed
make
sudo make install

Verify installation

/usr/local/nginx/sbin/nginx -version
sudo /usr/local/nginx/sbin/nginx   # start
sudo /usr/local/nginx/sbin/nginx -s stop   # stop

Optional: create a symlink for easier use

echo $PATH   # ensure /usr/local/nginx/sbin is in PATH or create a link
sudo ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx
nginx -version   # test the symlink
sudo nginx   # start via symlink
sudo nginx -s stop

Uninstall

# Remove the symlink
sudo rm -f /usr/sbin/nginx
# Delete the installation directory
sudo rm -rf /usr/local/nginx
# If the source provides a make uninstall target
sudo make uninstall

Note: Because the software was installed outside a package manager, manual removal of files is required. Deleting the --prefix directory is sufficient if that option was used.

Conclusion

Convenience : apt‑get offers the highest convenience (automatic dependency resolution), followed by yum, with source compilation being the least convenient because dependencies must be handled manually.

Customizability : Compiling from source provides the greatest flexibility (custom configure options), while apt‑get uses mostly default settings.

Required privileges : Source compilation can be performed with minimal privileges, yum requires elevated rights, and apt‑get typically needs root access; in environments without root, source compilation is the viable option.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CompilationLinuxAPTpackage managementyumdpkg
Raymond Ops
Written by

Raymond Ops

Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.