🐧Linux Package Management (LPM)

🐧Linux Package Management (LPM)

🐧Unlocking the Power of Linux Packages

💻To install a package

[root@alpha1 ajeet]# yum install nginx

If you face any difficulty in installation like resolving the hostname try any public DNS like 8.8.8.8 by updating your /etc/resolv.confor restart network manager below are the images of troubleshooting.

[root@alpha1 ajeet]# sudo systemctl restart NetworkManager

💻 To remove a package

[root@alpha1 ajeet]# yum remove nginx

💻 Update or Upgrade a Package

[root@alpha1 ajeet]# yum upgrade nginx
[root@alpha1 ajeet]# yum update nginx

Upgrade - will install the latest package, no rollback

Update - will install the latest package and keep the old package, we can rollback if needed

💻 Yum Option/History/Undo-Redo

💻 Search or Retrieve Package Info

[root@alpha1 ajeet]# yum search nginx
[root@alpha1 ajeet]# yum info nginx

💻 YUM vs DNF vs APT

Descriptionyumdnfapt
Installs a packageyum install <package>dnf install <package>apt install <package>
Removes a packageyum remove <package>dnf remove <package>apt remove <package>
Updates installed packages to the latest versionsyum updatednf upgradeapt upgrade
Searches for a packageyum search <package>dnf search <package>apt search <package>
Lists all installed packagesyum list installeddnf list installedapt list --installed
Lists available updates for installed packagesyum check-updatednf check-updateapt list --upgradable
Cleans up cached package filesyum clean alldnf clean allapt clean
Updates the local package indexyum makecachednf makecacheapt update
Displays detailed information about a packageyum info <package>dnf info <package>apt show <package>
Upgrades the entire distribution (if available)Not applicablednf system-upgradeapt full-upgrade or apt dist-upgrade
Upgrades installed packages to the latest versionsyum upgradednf upgradeapt upgrade

💻 RPM to Try

DescriptionCommand
Install a package from a .rpm filerpm -ivh <package.rpm>
Upgrade a package from a .rpm filerpm -Uvh <package.rpm>
Remove a packagerpm -e <package>
List installed packagesrpm -qa
Show information about a packagerpm -qi <package>
List files in an installed packagerpm -ql <package>
Verify package integrityrpm -V <package>
Install a package and its dependenciesyum localinstall <package.rpm>
Rebuild RPM package from sourcerpmbuild -bb <specfile.spec>
Extract contents of an RPM packagerpm2cpio <package.rpm>
Compare two RPM packagesrpm -q --scripts <package1> <package2>
Check dependencies for an RPM packagerpm -qpR <package.rpm>
Query which package provides a filerpm -qf <file>
Query which package owns a filerpm -q --whatprovides <file>
Create an RPM database indexrpm --rebuilddb

💻 Some more piping

Description

Command

List installed packages sorted by installation date

rpm -qa --last | sort

Search for a package by keyword in installed packages

rpm -qa | grep <keyword>

Count the number of installed packages

rpm -qa | wc -l

List the largest installed packages

rpm -qa --queryformat "%10{size} %{name}\n" | sort -rn | head

Remove all dependencies of a specific package

rpm -e --nodeps <package>

Extract the contents of an RPM package and search for a file

rpm2cpio <package.rpm> | cpio -idmv | grep <file>

Show only package names without versions

rpm -qa --queryformat "%{NAME}\n"

Show only package versions

rpm -qa --queryformat "%{VERSION}\n"

List dependencies for a package

rpm -qpR <package.rpm>

List files in an installed package starting with a specific prefix

rpm -ql <package> | grep ^<prefix>

Thank you for joining me on this journey through Linux Process Management (LPM). I truly appreciate your passion and dedication to learning. Keep exploring, stay curious, and happy coding!