What is Rpm? Rpm is package manager popular in Red Hat based operating systems. Rpm full name is Red Hat Package Manager. Rpm uses rpm as package extension and format. Rpm packages are generally distributed from repositories on the internet but using usb, optical media or other ways is popular too in the old days. Yum is the online package manager used to get rpm packages from network or internet repositories.
Yum files are named like below with name, version,release,architecture.
As stated before repositories are used to hold rpm packages on the internet but also a CD can be used as repository in rare situations. Repositories are used but yum/dnf commands.
Generally Rpm packages are provided by repository and package managers like yum, dnf. But there is alternative sites those provides Rpm packages download manually.
Source code of packages are distributed with srpm packages. Srpm packages are zipped with tar.gz or tar.bz2
PatchRPM and DeltaRpm
Rpm packages provide some options to makes download size smaller. Packages includes a lot of different type of files. But not all files are changed. To makes pacakges smaller only changed files are distributed in Deltarpm’s.
Rpm packages have generally dependencies which means if we want to install some package we need to install other related packages before installing it. But We skip this and install some package with -ivh parameters.
$ rpm -ivh tmux-1.8-4.el7.x86_64.rpm
We need root privileges to install rpm package. In our example we tried to install tmux but as we see in message it is installed all ready.
As we know Rpm packages have dependencies which means to install a package other packages may be needed. The needed packages must be installed before install current package. We can check dependencies like below.
rpm -qpR tmux-1.8-4.el7.x86_64.rpm
As we see tmux package depends on sh, standard C library, ncurses, Event library etc.
Install Omitting Dependency Check
Normally if we try to install package which have unmet dependency it will give error and do not installed. There is a way to install packages with unmet dependencies with forcefully. We will provide -nodeps parameter for installation.
$ rpm -ivh --nodeps tmux-1.8-4.el7.x86_64.rpm
Yum is used to download and install automatically but in some cases we may need to download package and install another system or etc. We can download a rpm package with command named yumdownloader like below. Yumdownloader do not needs any privilege for download operation.
$ yumdownloader tmux
We only provide package name to the yumdownloader.
Check Installed RPM Package
Rpm database holds information about installed packages. we can query this database like below. If the Rpm/application is installed the full package name is printed. If the application is not install a message like package not installed gived.
$ rpm -q tmux
List All Files Of Installed RPM Package
We may need to list files of and installed Rpm package. It is very similar to the checking process we will just add an -l parameter like below.
$ rpm -ql tmux
List Recently Installed RPM Packages
We may want to list lastly installed Rpm packages. But keep in mind that will generate a lot of line.
rpm -qa --last
I cannot put a screenshot here because it exceeds my terminal history. So I can put some limit or pagination to this list.
rpm -qa --last | less
List All Installed RPM Packages
Another way to list installed packages is listing all packages not just latest installed.
Using less in this situation is more practical. We can also search command output with less.
$ rpm -qa | less
If an Rpm package is all ready installed we can upgrade existing package to newer one. Advantage of upgrade is that after upgrade old package is also hold as a backup and if new package do not work old package can be used.
rpm -Uvh tmux-1.8-4.el7.x86_64.rpm
Uninstall RPM Package
Uninstalling or erasing and Rpm package can be done with -e parameter like below.
$ rpm -evv tmux-1.8-4.el7.x86_64.rpm
Uninstall RPM Package Without Dependencies
We can only uninstall package itself and hold dependency packages in the system.
$ rpm -ev --nodeps tmux
Alternative way to remove Rpm package is not erasing dependencies.
Query File Name To Find Related RPM Package
Sometimes we need to find related Rpm package from a file name.
rpm -qf /bin/sh
Get Info About Installed RPM Package
We can get information about and installed Rpm package like name version, release, size, url etc.
$ rpm -qi bash
Get Information About RPM Package
Actually Rpm provides a lot of important information about packages and its content. We can list and Rpm package information without installing it.
$ rpm -qip tmux-1.8-4.el7.x86_64.rpm
Query Documentation Of Installed RPM Package
Documentation of an installed Rpm package can be get like below. It is similar to finding Rpm package name from a file.
$ rpm -qdf /bin/bash
Verify RPM Package
We can check and Rpm package and verify against the Rpm database. to verify -Vp parameters should be provided.
$ rpm -Vp tmux-1.8-4.el7.x86_64.rpm
Verify All RPM Packages
We can verify all installed Rpm packages. Verify process will look into the Rpm database to complete this job. Keep in mind that this will require a lot of time.
$ rpm -Va
Import GPG Key Of RPM Package
GPG is a security protocol to verify authenticity. GPG is used recently to eliminate rouge repositories and Rpm packages but to benefit from this protocol GPG must be configured for Rpm. To configure GPG signs must be imported.
$ rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
List All Imported RPM GPG Keys
We can list existing or imported GPG keys like below.
$ rpm -qa gpg-pubkey*
Rebuild Corrupted RPM Database
Some time Rpm database can be get corrupted. Corrupted Rpm database can not be updated or used. So to get it into working condition Rpm database should be rebuild like below.
$ cd /var/lib
$ rm __db*
$ rpm --rebuilddb
$ rpmdb_verify Packages
Here we go the /var/lib and remove uncomplete database packages. Then run rpm rebuild command.