Linux RPM Command With Examples For CentOS, RedHat, Fedora – POFTUT

Linux RPM Command With Examples For CentOS, RedHat, Fedora

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.

Description

Yum files are named like below with name, version, release, architecture.

Repositories

As stated before repositories are used to hold rpm packages on the internet but also a CD can be used as a repository in rare situations. Repositories are used but yum/dnf commands.

Rpm Search

Generally, Rpm packages are provided by repository and package managers like yum, dnf. But there are alternative sites that provide Rpm packages download manually.

http://rpm.pbone.net/

Srpm

Source code of packages is distributed with srpm packages. Srpm packages are zipped with tar.gz or tar.bz2

PatchRPM and DeltaRpm

Rpm packages provide some options to makes the download size smaller. Packages include a lot of different type of files. But not all files are changed. To makes packages smaller only changed files are distributed in Deltarpm’s.

Rpm Install

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 Install

Rpm Install

We need root privileges to install the rpm package. In our example, we tried to install tmux but as we see in message it is installed already.

Check Dependency

As we know Rpm packages have dependencies which mean to install a package other packages may be needed. The needed packages must be installed before installing the current package. We can check dependencies like below.

Rpm dependency check

As we see tmux package depends on sh, standard C library, ncurses, Event library, etc.

LEARN MORE  How To Remove Packages From Ubuntu, Debian, Mint and Kali with Apt-Get Uninstall Command with Examples

Install Ignoring Dependency-Check

Normally if we try to install a package which has 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 --nodepsoption for installation.

Install Omitting Dependency Check

Install Omitting Dependency-Check

Download Rpm

Yum is used to downloading and installing automatically but in some cases, we may need to download package and install another system or etc. We can download an rpm package with a command named yumdownloader like below. yumdownloader do not need any privilege for download operation.

Download Rpm

Download Rpm

We only provide a 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.

Check Installed RPM Package

Check Installed RPM Package

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 -lparameter like below.

List files of installed packages

List Recently Installed RPM Packages

We may want to list lastly installed Rpm packages. But keep in mind that will generate a lot of lines.

I cannot put a screenshot here because it exceeds my terminal history. So I can put some limit or pagination to this list.

LEARN MORE  How To List All Repository Packages With Yum Command

List Recently Installed RPM Packages

List Recently Installed RPM Packages

As we can this will print the date of the RPM package installation with time information. In the screenshot for example kdeadmin package installed 24 November at 09:50:33 .

List All Installed RPM Packages

Another way to list installed packages is to listing all packages not just latest installed.

Using less in this situation is more practical. We can also search for command output with less.

List Recently Installed RPM Packages

List Recently Installed RPM Packages

Upgrade RPM Packages

If an Rpm package is all ready installed we can upgrade existing package to a newer one. Advantage of the upgrade is that after upgrade old package is also held as a backup and if the new package does not work old package can be used.

Upgrade RPM Packages

Upgrade RPM Packages

Uninstall RPM Package

Uninstalling or erasing and Rpm package can be done with -e parameter like below.

Uninstall RPM Package

Uninstall RPM Package

Uninstall RPM Package Without Dependencies

We can only uninstall package itself and hold dependency packages in the system.

Uninstall RPM Package Without Dependencies

Uninstall RPM Package Without Dependencies

An 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.

Query File Name To Find Related RPM Package

Query File Name To Find Related RPM Package

Get Info About Installed RPM Package

We can get information about and installed Rpm package like name version, release, size, url, etc.

Get Info About Installed RPM Package

Get Info About Installed RPM Package

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.

LEARN MORE  How To Add New Repository To Apt In Linux?

Get Information About RPM Package

Get Information About RPM Package

Query Documentation Of Installed RPM Package

Documentation of an installed Rpm package can get like below. It is similar to finding Rpm package name from a file.

Query Documentation Of Installed RPM Package

Query Documentation Of Installed RPM Package

Verify RPM Package

We can check and Rpm package and verify against the Rpm database. to verify -Vp parameters should be provided.

Verify RPM Package

Verify RPM Package

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. We will use -a or --all for this operation.

Verify All RPM Packages

Verify All RPM Packages

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.

List All Imported RPM GPG Keys

We can list existing or imported GPG keys like below.

List All Imported RPM GPG Keys

List All Imported RPM GPG Keys

As we can see from the screenshot that GPG keys have a different naming convention like gpg-pubkey-GUID where GUID or UID is a unique identifier to prevent name collision.

Initialize RPM Database

If we want to create a new RPM database which will hold installed package information we can use the --initdb option. This will create a new, empty, fresh database.

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 rebuilt like below.

Here we go the /var/liband remove uncomplete database packages. Then run rpm rebuild command.

1 Response

  1. 07/11/2017

    […] Linux Rpm Command With Examples […]

Leave a Reply

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

Enjoy this blog? Please spread the word :)