Package management

As I have to deal with both Red Hat and Debian based Linux distributions, I decided to make my own comparison cheat-sheet for the package management. It would look really nice as table where everything is side-by-side but it would not fit here in that way. Note for beginners: rpm/yum/repoquery/yumdownloader are package management tools in Red Hat based distros and apt*/dpkg* in Debian based distros.

  • Refresh information coming from repositories
yum clean metadata
apt-get update

Note: yum will reload package info on next run.

  • Search package from available repositories by partial package name
yum list <partial package name> 
apt-cache search <search string>
  • Search package from available repositories by string in information/description
yum search <search string>
apt-cache search <search string>
  • Install package from repository
yum install <package name>
apt-get install <package name>
  • Install package from given package file, without dependencies
rpm -ivh <rpm-file>
dpkg -i <deb-file>

Note: You will keep getting errors with Debian tools like dpkg/apt until you satisfy dependencies.

  • Install package from given file and resolve dependencies
yum install <rpm-file>
dpkg -i <deb-file>; apt-get -f install

Note: yum localinstall <rpm-file> has same results

  • Reinstall package, useful if you have manually deleted/changed some content
yum reinstall <package name>
  • Upgrade package with new version from package file or install if it is not yet installed
 rpm -Uvh <rpm-file>
  • Upgrade all packages / Install all upgrades
yum update
apt-get upgrade
  • Upgrade specific package
yum update <package name>
  • Upgrade specific package to specific version
yum upgrade-to <package name>-<version>

Note: For example yum upgrade-to wget-1.11.4-3.el5_8.2

  • Remove installed package but keep configuration files
dpkg -r <package name>
apt-get remove <package name>
  • Remove installed packages along with all configuration files and created directories
rpm -ev <package name>
yum remove <package name>
dpkg -P <package name>

Note: Another word for this operation is purge

  • Remove automatically installed packages
apt-get autoremove

Note: This will remove packages which were installed automatically to satisfy dependencies

  • Download package from repository
apt-get download <package name>
yumdownloader <package name>

Note: This is just download without installing

  • Display installed package name from which specific file originated
rpm -qf <filename with full path>
repoquery --plugins -f <filename with full path>
dpkg -S <filename with full path>
  • Display not installed package name which will provide specific file
yum provides <filename with full path>
apt-file -Fl search <filename with full path>

Note: Run apt-file update first

  • Display all installed packages
rpm -qa
yum list installed
repoquery --plugins -a --installed
dpkg --list
  • Display all packages available from repositories
yum list
repoquery --plugins -a
apt-cache pkgnames
  • Display information about installed package
rpm -qi <package name>
dpkg -p <package name>
  • Display information about uninstalled package file
rpm -qpi <rpm-file>
dpkg --info <deb-file>
  • Display file lists (contents) of uninstalled package file
rpm -qpl <rpm-file>
dpkg -c <deb-file>
  • Display file lists (contents) of installed package (originating files)
rpm -ql <package name>
dpkg -L <package name>
  • Display information about package available from repository
yum info <package name>
repoquery --plugins -i <package name>
apt-cache showpkg <package name>
  • Display file list of package available from repository

 

repoquery --plugins -l <package name>
  • Display list of most recently installed packages with dates
 rpm -qa --last
  • Display package management history
 yum history

Note: If history command does not exist, your yum version is too old

  • Display configuration files of specific package
 rpm -qc <package name>
  • Display configuration files associated with specific file
 rpm -qcf <filename with full path>
  • Display package dependencies
rpm -qpR <rpm-file>
rpm -qR <package name>
  • Clean package cache only
 yum clean packages
  • Clean package cache, metadata and everything else
yum clean all
apt-get clean
  • Extract rpm / deb package contents without installing
rpm2cpio <rpm-file> |cpio -idmv
dpkg -x <deb-file> <target-directory>
  • Is rpm file relocatable ?
rpm -qpi <rpm-file> | grep Relocations
  • Install package to different location – can be done by root and non-root user if package is relocatable and you have write rights to the specified location
rpm -Uvh --prefix /alternate/location <relocatable-rpm-file>
  • Display RPM GPG key signature and ID – useful when adding channel to Spacewalk/ RHEL Satellite. Green and Blue is the signature. Blue is ID.
# gpg --quiet --with-fingerprint RPM-GPG-KEY-graylog
pub 2048R/B1606F22 2014-06-04 TORCH GmbH <packages@torch.sh>
Key fingerprint = 28AB 6EB5 7277 9C2A D196 BE22 D44C 1D8D B160 6F22
  • Install rpm without GPG check
# yum --nogpgcheck install <package name>
  • Install GPG key
# rpm --import <gpg-key-file>

  This page may continue and get updates over time. Feel free to add your favorites and/or missing things in comments. If you found this useful, say thanks, click on some banners or donate, I can always use some beer money.

Leave a Reply

Your email address will not be published. Required fields are marked *