RPM Commands

Common RPM (RedHat Package Manager) commands to obtain information about RPM packages installed on the system, Install, Remove or otherwise manipulate system packages.

Applicable to Centos Versions:

  • Centos 5.x
  • Centos 6.x

Requirements

Explanation of requirements.

  1. An Official Centos install
  2. Installed & working RPM (This should be default)

RPM Commands (RedHat Package Manager)

Here are a few of the most used RPM commands:

  1. Install a local RPM:
  2. rpm -ivh /path/to/my.rpm or: rpm -Uvh /path/to/my.rpm
  3. Remove a locally installed RPM:
  4. rpm -e /path/to/my.rpm
  5. Upgrade/Update a locally installed RPM:
  6. rpm -Uvh /path/to/my.rpm
  7. Find out what package a particular file belongs to:
  8. rpm -qf /usr/bin/ssh
  9. Find useful information about a package:
  10. rpm -qi openssh
  11. Find out when a package was installed:
  12. rpm -q openssh --last
  13. List the dependencies of a package:
  14. rpm -qR openssh
  15. List all gpg keys known by RPM on the system:
  16. rpm -q gpg-pubkey --qf '%{name}-%{version}-%{release} --> %{summary}\n'
  17. Install an RPM from a website or anonymous FTP server:
  18. rpm -ivh http://www.somewebsite.com/package.rpm
    rpm -ivh ftp://ftp.somewebsite.com/package.rpm
  19. Repair and rebuild a corrupted RPM database:
  20. rm -f /var/lib/rpm/__db* && rpm -vv --rebuilddb
  21. Find out what locations the files from a specific RPM were installed to:
  22. rpm -ql openssh
  23. Make a text file of all the packages currently installed on the system sorted alphabetically:
  24. rpm -qa | sort -d | uniq > all_packages.txt
  25. Make a CSV file with all currently installed packages sorted alphabetically by group:
  26. (note: This command should be run as a single command, make sure there is a space between each section and the command is run as one single command or copy and paste the command as it is displayed.)
    
    echo "Group,Name,Arch,Version,Summary,Repo,Size" > ~/available-packages-by-group.csv && repoquery -a --pkgnarrow=available --qf '%{GROUP},%{NAME},%{ARCH},%{VERSION},"%{SUMMARY}",%{REPOID},%{INSTALLEDSIZE}' | sort -d >> ~/available-packages-by-group.csv

Common Problems & Fixes

Check the Centos.org wiki for further useful information and hints.

More Information

Any additional information or notes.

Disclaimer

We test this stuff on our own machines, really we do. But you may run into problems, if you do, come to #centoshelp on irc.freenode.net

Added Reading


© 2012 CentosHelp.org