Master Linux Package Management: yum, apt, dpkg & Source Compilation
An in‑depth guide walks you through Linux package management using yum, apt/apt‑get, dpkg/rpm, and source compilation, detailing commands for updating, installing, upgrading, removing, version locking, and verification, plus a comparative analysis of convenience, customizability, and required permissions.
yum
Update source: sudo yum clean all && sudo yum makecache Install package: sudo yum install <package_name>[-<version>] Upgrade package: sudo yum upgrade <package_name> or sudo yum update for all
Remove package: sudo yum remove <package_name> Downgrade package: sudo yum downgrade <package_name>-<version> Search package: yum search <package_name> List installed: yum list installed [<package_name>] Show available versions: yum list <package_name> --showduplicates Version lock: sudo yum versionlock add <package_name>[-version] Unlock version: sudo yum versionlock delete <package_name> Clear all locks: sudo yum versionlock clear List locks: yum versionlock list Tip: To use version locking, install the plugin with sudo yum install yum-plugin-versionlock.
apt/apt-get
Edit sources: sudo apt edit-sources [<source_name>] Update source list: sudo apt update or sudo apt-get update Install package: sudo apt install <package_name>[=<version>] (same for apt-get)
Upgrade package: sudo apt upgrade <package_name> Remove package: sudo apt remove <package_name> Purge package (remove config files): sudo apt purge <package_name> List installed: apt list [<package_name>] -i Search 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 packages: sudo apt-get autoremove Show package history (available versions): apt-cache policy <package_name> List all versions: apt list <package_name> -a or apt-cache madison <package_name> Hold (lock) version: sudo apt-mark hold <package_name> Unhold (unlock) version: sudo apt-mark unhold <package_name> Show held packages:
apt-mark showholddpkg / rpm
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 (remove config files): sudo dpkg -P <deb_name> Search installed packages: dpkg -l <deb_name> or rpm -qa <rpm_name> Show package info: dpkg -s <deb_name> or rpm -qi <rpm_name> List package files: dpkg -L <deb_name> or rpm -ql <rpm_name> Find owning package of a file: dpkg -S <file_name> or
rpm -qf <file_name>Source Compilation Installation
Prepare source code package.
wget https://nginx.org/download/nginx-1.24.0.tar.gz
tar -xzvf nginx-1.24.0.tar.gz
cd nginx-1.24.0Install build dependencies (example for nginx). sudo yum install pcre-devel zlib-devel Configure, compile and install.
./configure --prefix=/usr/local/nginx
make
sudo make installVerify installation.
/usr/local/nginx/sbin/nginx -version
sudo /usr/local/nginx/sbin/nginx
sudo /usr/local/nginx/sbin/nginx -s stopOptional: create a symbolic link for easier access.
echo $PATH
sudo ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx
nginx -version
sudo nginx
sudo nginx -s stopUninstall: remove the symlink and the installation directory, or run make uninstall if supported.
sudo rm -f /usr/sbin/nginx
sudo rm -rf /usr/local/nginx
# sudo make uninstall (if provided)Conclusion
Convenience: apt‑get is the most convenient (handles dependencies automatically), followed by dpkg , while source compilation requires manual dependency handling.
Customizability: Source compilation offers the highest customizability, allowing custom build options; dpkg is next, and apt‑get provides the least.
Required privileges: Source compilation can be performed with minimal privileges, dpkg needs moderate rights, and apt‑get typically requires root access.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
