There are several ways to install an RPM on CentOS. This guide covers the command line programs yum and rpm. There are GUI tools, such as PackageKit, to manage packages, but since the command line tools will always be available, those are what I will cover. In most cases, you probably want to use yum. Unlike rpm, yum can automatically install missing dependencies from your repositories. All commands in this guide must be executed as root or using a privilege escalation tool such as sudo.
If you are in a hurry, here is an example using rpm:
[root@centos7 ~]# rpm -i pam_krb5-2.4.8-6.el7.x86_64.rpm
There are a few things to consider when installing packages. Packages often have dependencies and they are typically signed with GPG.
Unlike rpm, yum will resolve dependencies for you. You can also manually install each dependency, or ignore them. Do not ignore them unless you know for certain they are met through other means or are not needed. For example, say you are installing an application that uses a database. Suppose that application has a dependency of MySQL, but you are going to use Postgres. In this case, you can probably safely ignore the MySQL dependency.
Your system comes with the GPG keys needed to verify signatures from the standard repositories. If you obtained the package(s) from another source, they are either not signed, or signed with a key you likely don’t have. When packages are signed, you have two choices. You can import the key, or ignore RPM’s signature verification process. I advise importing the key.
Installing From The Repositories
To install a package from the repositories, use yum:
[root@centos7 ~]# yum install zip Loaded plugins: fastestmirror, keys Loading mirror speeds from cached hostfile * base: repo1.ash.innoscale.net * extras: repo1.ash.innoscale.net * updates: repo1.ash.innoscale.net Resolving Dependencies --> Running transaction check ---> Package zip.x86_64 0:3.0-11.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: zip x86_64 3.0-11.el7 base 260 k Transaction Summary ================================================================================ Install 1 Package Total download size: 260 k Installed size: 796 k Is this ok [y/d/N]: y Downloading packages: zip-3.0-11.el7.x86_64.rpm | 260 kB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : zip-3.0-11.el7.x86_64 1/1 Verifying : zip-3.0-11.el7.x86_64 1/1 Installed: zip.x86_64 0:3.0-11.el7 Complete! [root@centos7 ~]#
Installing From an RPM File
To install from a file, you can use either rpm with the -i option or yum.
Using rpm:
[root@centos7 ~]# rpm -i /root/krb5-workstation-1.15.1-34.el7.x86_64.rpm [root@centos7 ~]#
Using yum:
[root@centos7 ~]# yum install /root/krb5-workstation-1.15.1-34.el7.x86_64.rpm Loaded plugins: fastestmirror, keys Examining /root/krb5-workstation-1.15.1-34.el7.x86_64.rpm: krb5-workstation-1.15.1-34.el7.x86_64 Marking /root/krb5-workstation-1.15.1-34.el7.x86_64.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package krb5-workstation.x86_64 0:1.15.1-34.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: krb5-workstation x86_64 1.15.1-34.el7 /krb5-workstation-1.15.1-34.el7.x86_64 2.5 M Transaction Summary ================================================================================ Install 1 Package Total size: 2.5 M Installed size: 2.5 M Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : krb5-workstation-1.15.1-34.el7.x86_64 1/1 Verifying : krb5-workstation-1.15.1-34.el7.x86_64 1/1 Installed: krb5-workstation.x86_64 0:1.15.1-34.el7 Complete! [root@centos7 ~]#
Ignoring Dependencies
This is only possible with rpm using the --nodeps option.
[root@centos7 ~]# rpm -i rsyslog-relp-8.40.0-1.el7.x86_64.rpm warning: rsyslog-relp-8.40.0-1.el7.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID e00b8985: NOKEY error: Failed dependencies: librelp >= 1.2.17 is needed by rsyslog-relp-8.40.0-1.el7.x86_64 librelp.so.0()(64bit) is needed by rsyslog-relp-8.40.0-1.el7.x86_64 rsyslog = 8.40.0-1.el7 is needed by rsyslog-relp-8.40.0-1.el7.x86_64 [root@centos7 ~]# rpm --nodeps -i rsyslog-relp-8.40.0-1.el7.x86_64.rpm warning: rsyslog-relp-8.40.0-1.el7.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID e00b8985: NOKEY [root@centos7 ~]#
Notice how when I used the --nodeps option, there was no error related to failed dependencies. The warning is due to rpm not recognizing the GPG key used to sign the package. The package was still installed. It is generally a good idea to heed these warnings. They are there to protect you from malicious parties installing malware on your system. If you aren't familiar with how cryptographic signatures work, it would be worthwhile to read the section on signatures in my introduction to cryptography.
Ignoring Signatures With Yum
I strongly advise against this. The best thing to do is import the key. Third party repositories usually have instructions on how to import their key(s).
If you are installing from a file, yum will install from a file without checking to see if it is signed by a known key. Make sure you trust the package source before installing it.
When installing from a repository, it depends on whether the gpgcheck option is enabled. When using new repositories, yum will often prompt you to import a key if the repository configuration has one defined. If not, it will output an error and refuse to install the package.
[root@centos7 ~]# yum install libfastjson4 Loaded plugins: fastestmirror, keys Loading mirror speeds from cached hostfile * base: repo1.ash.innoscale.net * extras: repo1.ash.innoscale.net * updates: repo1.ash.innoscale.net rsyslog_v8 | 2.5 kB 00:00 Resolving Dependencies --> Running transaction check ---> Package libfastjson4.x86_64 0:0.99.8-1.el7.centos will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: libfastjson4 x86_64 0.99.8-1.el7.centos rsyslog_v8 64 k Transaction Summary ================================================================================ Install 1 Package Total size: 64 k Installed size: 182 k Is this ok [y/d/N]: y Downloading packages: warning: /var/cache/yum/x86_64/7/rsyslog_v8/packages/libfastjson4-0.99.8-1.el7.centos.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID e00b8985: NOKEY Public key for libfastjson4-0.99.8-1.el7.centos.x86_64.rpm is not installed [root@centos7 ~]#
To get around this, you would use the --nogpgcheck option:
[root@centos7 ~]# yum install --nogpgcheck libfastjson4 Loaded plugins: fastestmirror, keys Loading mirror speeds from cached hostfile * base: repo1.ash.innoscale.net * extras: repo1.ash.innoscale.net * updates: repo1.ash.innoscale.net rsyslog_v8 | 2.5 kB 00:00:00 Resolving Dependencies --> Running transaction check ---> Package libfastjson.x86_64 0:0.99.4-3.el7 will be obsoleted ---> Package libfastjson4.x86_64 0:0.99.8-1.el7.centos will be obsoleting --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: libfastjson4 x86_64 0.99.8-1.el7.centos rsyslog_v8 64 k replacing libfastjson.x86_64 0.99.4-3.el7 Transaction Summary ================================================================================ Install 1 Package Total size: 64 k Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : libfastjson4-0.99.8-1.el7.centos.x86_64 1/2 [root@centos7 ~]# yum install --nogpgcheck libfastjson4 Loaded plugins: fastestmirror, keys Loading mirror speeds from cached hostfile * base: repo1.ash.innoscale.net * extras: repo1.ash.innoscale.net * updates: repo1.ash.innoscale.net base | 3.6 kB 00:00 extras | 3.4 kB 00:00 rsyslog_v8 | 2.5 kB 00:00 updates | 3.4 kB 00:00 updates/7/x86_64/primary_db | 1.3 MB 00:00 Resolving Dependencies --> Running transaction check ---> Package libfastjson4.x86_64 0:0.99.8-1.el7.centos will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: libfastjson4 x86_64 0.99.8-1.el7.centos rsyslog_v8 64 k Transaction Summary ================================================================================ Install 1 Package Total size: 64 k Installed size: 182 k Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Warning: RPMDB altered outside of yum. Installing : libfastjson4-0.99.8-1.el7.centos.x86_64 1/1 Verifying : libfastjson4-0.99.8-1.el7.centos.x86_64 1/1 Installed: libfastjson4.x86_64 0:0.99.8-1.el7.centos Complete! [root@centos7 ~]#