RPM Commands in Linux with Examples
Abstract: package GeoIP-1.5.0-11.el7.x86_64 is already installed 7. How to replace RPM package installed We can use -ivh --replacepkgs parameters to replace a p
RPM(Redhat Package Manager) is a command line package management utility used for installing, uninstalling, updating, querying and verifying software packages.
In this tutorial, I will explain some of the most common Linux rpm commands for a system admin. Some of the RPM Based Linux Distros are Redhat, Centos, Fedora, and OpenSuse. Yum and DNF are frontends for RPM Management which have more features and could overcome the limitations it has.
How to get RPM packagesThere are several methods available to get RPM packages as shown below.
How to use the Command Line or Term...To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video
How to use the Command Line or Terminal for Absolute Beginners- software CD/DVD
- CentOS Mirror
- RedHat (Need account)
- Any open repository websites
- Install : It is used to install any RPM package.
- Remove : It is used to erase, remove or un-install any RPM package.
- Upgrade : It is used to update the existing RPM package.
- Query : It is used to query any RPM package.
- Verify : It is used to verify RPM packages.
GeoIP application GeoIP-1.5.0-11.el7.x86_64.rpm
is a RPM Package Library for country/city/organization to IP address or hostname mapping . GeoIP
is the package name, version is 1.5.0-11.el7
, release is 7
and architecture .x86_64
.
After we have downloaded a package and we want to know the information of a package before installing. We can use -qip
option (query info package) to list the information of a package.
$ sudo rpm -qip GeoIP-1.5.0-11.el7.x86_64.rpm
output
Name : GeoIP
Version : 1.5.0
Release : 11.el7
Architecture: x86_64
Install Date: (not installed)
Group : Development/Libraries
Size : 2905020
License : LGPLv2+ and GPLv2+ and CC-BY-SA
Signature : RSA/SHA256, Sun 20 Nov 2016 05:49:19 PM UTC, Key ID 24c6a8a7f4a80eb5
Source RPM : GeoIP-1.5.0-11.el7.src.rpm
Build Date : Sat 05 Nov 2016 08:29:17 PM UTC
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem
Vendor : CentOS
URL : http://www.maxmind.com/app/c
Summary : Library for country/city/organization to IP address or hostname mapping
Description :
GeoIP is a C library that enables the user to find the country that any IP
address or hostname originates from. It uses a file based database that is
accurate as of June 2007 and can optionally be updated on a weekly
basis by installing the GeoIP-update package. This database simply contains IP
blocks as keys, and countries as values. This database should be more complete
and accurate than using reverse DNS lookups.
This package includes GeoLite data created by MaxMind, available from
http://www.maxmind.com/
2. How to install RPM package
We can use -ivh
parameters to install a particular package as shown below.
$ sudo rpm -ivh GeoIP-1.5.0-11.el7.x86_64.rpm
Output
Preparing... ################################# [100%]
package GeoIP-1.5.0-11.el7.x86_64 is already installed
3. How to check an installed RPM package
We can use -q
option with package name, It will show whether an rpm package installed or not.
$ sudo rpm -q GeoIP
output
GeoIP-1.5.0-11.el7.x86_64
4. How to List all files for particular installed RPM package
We can list all the files of an installed rpm packages, By using the -ql
option with rpm command.
$ sudo rpm -ql GeoIP
output
/etc/GeoIP.conf
/etc/GeoIP.conf.default
/usr/bin/geoiplookup
/usr/bin/geoiplookup6
/usr/bin/geoipupdate
/usr/lib64/libGeoIP.so.1
/usr/lib64/libGeoIP.so.1.5.0
/usr/lib64/libGeoIPUpdate.so.0
/usr/lib64/libGeoIPUpdate.so.0.0.0
/usr/share/GeoIP
/usr/share/GeoIP/GeoIP-initial.dat
/usr/share/GeoIP/GeoIP.dat
/usr/share/GeoIP/GeoIPASNum.dat
/usr/share/GeoIP/GeoIPASNumv6.dat
/usr/share/GeoIP/GeoIPCity.dat
/usr/share/GeoIP/GeoIPCityv6.dat
/usr/share/GeoIP/GeoIPCountry.dat
/usr/share/GeoIP/GeoIPCountryv6.dat
/usr/share/GeoIP/GeoIPv6-initial.dat
...
5. How to list recently installed RPM packages
We can use -qa
option with --last
, It will list all the recently installed rpm packages.
$ sudo rpm -qa --last
output
GeoIP-1.5.0-11.el7.x86_64 Sat 01 Sep 2018 11:34:09 AM UTC
wget-1.14-15.el7_4.1.x86_64 Sun 26 Aug 2018 03:21:02 PM UTC
iwl7265-firmware-22.0.7.0-62.2.el7_5.noarch Thu 16 Aug 2018 02:10:18 PM UTC
libgomp-4.8.5-28.el7_5.1.x86_64 Thu 16 Aug 2018 02:10:15 PM UTC
iwl2030-firmware-18.168.6.1-62.2.el7_5.noarch Thu 16 Aug 2018 02:10:15 PM UTC
iptables-1.4.21-24.1.el7_5.x86_64 Thu 16 Aug 2018 02:10:15 PM UTC
yum-plugin-fastestmirror-1.1.31-46.el7_5.noarch Thu 16 Aug 2018 02:10:14 PM UTC
iwl6000-firmware-9.221.4.1-62.2.el7_5.noarch Thu 16 Aug 2018 02:10:14 PM UTC
iwl4965-firmware-228.61.2.24-62.2.el7_5.noarch Thu 16 Aug 2018 02:10:14 PM UTC
iwl105-firmware-18.168.6.1-62.2.el7_5.noarch Thu 16 Aug 2018 02:10:14 PM UTC
iwl100-firmware-39.31.5.1-62.2.el7_5.noarch Thu 16 Aug 2018 02:10:13 PM UTC
iwl1000-firmware-39.31.5.1-62.2.el7_5.noarch Thu 16 Aug 2018 02:10:13 PM UTC
ca-certificates-2018.2.22-70.0.el7_5.noarch Thu 16 Aug 2018 02:10:13 PM UTC
iwl6000g2b-firmware-17.168.5.2-62.2.el7_5.noarch Thu 16 Aug 2018 02:10:12 PM UTC
...
6. How to install RPM package without dependencies
We can use -ivh
parameters with --nodeps
stands for no dependencies check, To install a particular package without dependencies, As shown below.
$ sudo rpm -ivh --nodeps GeoIP-1.5.0-11.el7.x86_64.rpm
Output
Preparing... ################################# [100%]
package GeoIP-1.5.0-11.el7.x86_64 is already installed
7. How to replace RPM package installed
We can use -ivh --replacepkgs
parameters to replace a particular package installed as shown below.
$ sudo rpm -ivh --replacepkgs GeoIP-1.5.0-11.el7.x86_64.rpm
Output
Preparing... ################################# [100%]
Updating / installing...
1:GeoIP-1.5.0-11.el7 ################################# [100%]
Remove 8. How to uninstall RPM package
We can use -e
parameters to uninstall particular package installed without dependencies (don't check dependencies) as shown below.
$ sudo rpm -e --nodeps GeoIP
Now type command below to ensure the GeoIP not installed.
$ sudo rpm -q GeoIP
Output
package GeoIP is not installed
Upgrade 9. How to upgrade RPM package installed
We can use -Uvh
parameters to upgrade a particular package installed as shown below.
$ sudo rpm -Uvh GeoIP-1.5.0-11.el7.x86_64.rpm
Output
Preparing... ################################# [100%]
package GeoIP-1.5.0-11.el7.x86_64 is already installed
Query 10. How to query all installed package
We can use -a
parameters along with q
to query all installed packages on the server as shown below.
$ sudo rpm -qa
Output
python-firewall-0.4.4.4-14.el7.noarch
ncurses-base-5.9-14.20130511.el7_4.noarch
plymouth-0.8.9-0.31.20140113.el7.centos.x86_64
kbd-misc-1.15.5-13.el7.noarch
vim-common-7.4.160-4.el7.x86_64
bash-4.2.46-30.el7.x86_64
dmidecode-3.0-5.el7.x86_64
filesystem-3.2-25.el7.x86_64
kbd-1.15.5-13.el7.x86_64
vim-enhanced-7.4.160-4.el7.x86_64
firewalld-0.4.4.4-14.el7.noarch
....
11. How to query particular package
We can use grep
command to find about a particular package is installed or not as shown below.
$ sudo rpm -qa | grep GeoIP
Output
GeoIP-1.5.0-11.el7.x86_64
12. How to query a file that belongs which RPM Package
In example number 9 we type command to list all files of an installed RPM package, Now we want to know /usr/lib64/libGeoIP.so.1.5.0
file belongs which RPM Package.
$ sudo rpm -qf /usr/lib64/libGeoIP.so.1.5.0
output
GeoIP-1.5.0-11.el7.x86_64
Verify 13. How to get information for a particular package
We can use -i
parameters along with q
to get information for a particular package as shown below.
$ sudo rpm -qi GeoIP
Output
Name : GeoIP
Version : 1.5.0
Release : 11.el7
Architecture: x86_64
Install Date: Thu 16 Aug 2018 02:04:09 PM UTC
Group : Development/Libraries
Size : 2905020
License : LGPLv2+ and GPLv2+ and CC-BY-SA
Signature : RSA/SHA256, Sun 20 Nov 2016 05:49:19 PM UTC, Key ID 24c6a8a7f4a80eb5
Source RPM : GeoIP-1.5.0-11.el7.src.rpm
Build Date : Sat 05 Nov 2016 08:29:17 PM UTC
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem
Vendor : CentOS
URL : http://www.maxmind.com/app/c
Summary : Library for country/city/organization to IP address or hostname mapping
Description :
GeoIP is a C library that enables the user to find the country that any IP
address or hostname originates from. It uses a file based database that is
accurate as of June 2007 and can optionally be updated on a weekly
basis by installing the GeoIP-update package. This database simply contains IP
blocks as keys, and countries as values. This database should be more complete
and accurate than using reverse DNS lookups.
This package includes GeoLite data created by MaxMind, available from http://www.maxmind.com/
14. How to verify a RPM package
We can verify a package by comparing information of installed files of the package to the rpm database, By using -Vp
option (verify package).
$ sudo rpm -Vp GeoIP-1.5.0-11.el7.x86_64.rpm
15. How to verify all RPM packages
We can verify all the installed rpm packages, By using -Va
option (verify all).
$ sudo rpm -Va
output
S.5....T. c /etc/sysconfig/authconfig
S.5....T. c /etc/yum.repos.d/CentOS-Base.repo
.M....... c /etc/machine-id
.M....... g /etc/udev/hwdb.bin
.M....... g /var/lib/systemd/random-seed
.M....... c /etc/shadow
S.5....T. c /etc/ssh/sshd_config
.M....... c /etc/audit/rules.d/audit.rules
S.5....T. c /etc/NetworkManager/NetworkManager.conf
....L.... c /etc/pam.d/fingerprint-auth
....L.... c /etc/pam.d/password-auth
....L.... c /etc/pam.d/postlogin
...
Read Also:
- How to Download Packages without Installing on RPM Distros
- 21 DNF Commands to Manage RPM Based Linux Distributions
- How to Query Packages Using Linux RPM Command
An rpm package consists of program files, config files and a list of compiled software programs and libraries needed by the packages(dependencies). This rpm utility only works with packages that are built on '.rpm' format.