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.
- An Official Centos install
- Installed & working RPM (This should be default)
RPM Commands (RedHat Package Manager)
Here are a few of the most used RPM commands:
- Install a local RPM:
- Remove a locally installed RPM:
- Upgrade/Update a locally installed RPM:
- Find out what package a particular file belongs to:
- Find useful information about a package:
- Find out when a package was installed:
- List the dependencies of a package:
- List all gpg keys known by RPM on the system:
- Install an RPM from a website or anonymous FTP server:
- Repair and rebuild a corrupted RPM database:
- Find out what locations the files from a specific RPM were installed to:
- Make a text file of all the packages currently installed on the system sorted alphabetically:
- Make a CSV file with all currently installed packages sorted alphabetically by group:
1 |
rpm -ivh /path/to/my.rpm or: rpm -Uvh /path/to/my.rpm |
1 |
rpm -e /path/to/my.rpm |
1 |
rpm -Uvh /path/to/my.rpm |
1 |
rpm -qf /usr/bin/ssh |
1 |
rpm -qi openssh |
1 |
rpm -q openssh --last |
1 |
rpm -qR openssh |
1 |
rpm -q gpg-pubkey --qf '%{name}-%{version}-%{release} --> %{summary}\n' |
1 2 |
rpm -ivh http://www.somewebsite.com/package.rpm rpm -ivh ftp://ftp.somewebsite.com/package.rpm |
1 |
rm -f /var/lib/rpm/__db* && rpm -vv --rebuilddb |
1 |
rpm -ql openssh |
1 |
rpm -qa | sort -d | uniq > all_packages.txt |
1 2 3 |
(<em>note: This command should be run as a single command, </em>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
- http://www.rpm.org/
- http://docs.fedoraproject.org/drafts/rpm-guide-en/
- http://www.redhat.com/docs/books/max-rpm/index.html
- http://en.wikipedia.org/wiki/RPM_Package_Manager
Last Modified: 22 Apr, 2020 at 16:29:01