Tuesday , 19 June 2018
Latest topics!!

Managing Linux RPM packages – how to?

As a server admin, you people must have the knowledge of how to manage Linux RPMs via command line. Redhat Package Manager is abbreviated as RPM. Managing Linux packages via RPM commands should be a little tougher than managing it via YUM.

Using yum command should be better than rpm command after Red Hat Enterprise Linux 5, since it can update local yum database properly. RPM deals with .rpm files, which contains the actual information about the packages such as: what it is, from where it comes, dependencies info, version info etc.

To install a package via RPM command, you need to download it on your local machine or Server first. You can download it from the internet and then install it simply via Command Line Interface (CLI).

Here I going to introduce some basic and commonly using RPM commands. You an apply this to your Twin Bee servers.

Q. How to list all installed packages using rpm command?

This is an interesting command to query installed packages details from Linux CLI. That switch is “q.” See the examples pasted below:

# rpm -qa perl
perl-5.16.3-291.el7.x86_64

In the above example:

perl : Package name
5.16.3-291 : Is the version
el7 : Operating system
x86_64 : System architecture

Q. How to list all installed packages using rpm command?

You can use the switch “a” along with “q” to list all installed packages from CLI. See the sample output pasted below:

# rpm -qa
openssl-devel-1.0.1e-60.el7.x86_64
ModemManager-glib-1.6.0-2.el7.x86_64
libxslt-devel-1.1.28-5.el7.x86_64
libteam-1.25-4.el7.x86_64
t1lib-devel-5.1.2-14.el7.x86_64
mysql-community-client-5.6.35-2.el7.x86_64
glib-networking-2.42.0-1.el7.x86_64
uw-imap-devel-2007f-4.el7.1.x86_64
tar-1.26-31.el7.x86_64
.......

Q. How to install a package using rpm command?

To install a rpm, you can use the switch “i.” For a better user experience you can use the switch compo “ivh” for installation.

-i : install a package
-v : verbose
-h : print hash marks as the package archive is unpacked.

FYI, you need to download the rpm package first to the server prior to the installation process. Please see the example pasted below:

Here I’m going to install iftop using rpm command. As I stated, we need to download it first to our server. The rpm can be found from many websites like, redhat.com, rpmfind.com etc….

To download use the command pasted below:

wget ftp://195.220.108.108/linux/dag/redhat/el7/en/x86_64/dag/RPMS/iftop-1.0-0.pre3.el7.rf.x86_64.rpm

See the sample output pasted below:

# wget ftp://195.220.108.108/linux/dag/redhat/el7/en/x86_64/dag/RPMS/iftop-1.0-0.pre3.el7.rf.x86_64.rpm
--2017-01-31 08:36:46--  ftp://195.220.108.108/linux/dag/redhat/el7/en/x86_64/dag/RPMS/iftop-1.0-0.pre3.el7.rf.x86_64.rpm
           => ‘iftop-1.0-0.pre3.el7.rf.x86_64.rpm’
Connecting to 195.220.108.108:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /linux/dag/redhat/el7/en/x86_64/dag/RPMS ... done.
==> SIZE iftop-1.0-0.pre3.el7.rf.x86_64.rpm ... 49768
==> PASV ... done.    ==> RETR iftop-1.0-0.pre3.el7.rf.x86_64.rpm ... done.
Length: 49768 (49K) (unauthoritative)

100%[================================================================================>] 49,768       221KB/s   in 0.2s

2017-01-31 08:36:48 (221 KB/s) - ‘iftop-1.0-0.pre3.el7.rf.x86_64.rpm’ saved [49768]
ll iftop-1.0-0.pre3.el7.rf.x86_64.rpm
-rw-r--r--. 1 root root 49768 Jan 31 08:36 iftop-1.0-0.pre3.el7.rf.x86_64.rpm

Now use the “ivh” switch compo to install iftop om machine.

# rpm -ivh iftop-1.0-0.pre3.el7.rf.x86_64.rpm
warning: iftop-1.0-0.pre3.el7.rf.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:iftop-1.0-0.pre3.el7.rf          ################################# [100%]

That’s it!! Now you can monitor the traffic on your machine using iftop command.

Q. How to list recently installed packages using rpm command?

Use the switch “–last” to list out recently installed packages. Please see the example pasted below:

# rpm -qa --last
iftop-1.0-0.pre3.el7.rf.x86_64                Tue 31 Jan 2017 08:39:09 AM EST
luajit-devel-2.0.4-3.el7.x86_64               Mon 09 Jan 2017 05:06:57 PM EST
luajit-2.0.4-3.el7.x86_64                     Mon 09 Jan 2017 05:06:56 PM EST
GeoIP-devel-1.5.0-11.el7.x86_64               Mon 09 Jan 2017 05:04:45 PM EST
lua-devel-5.1.4-15.el7.x86_64                 Mon 09 Jan 2017 05:01:31 PM EST

Q. How to upgrade a package using rpm command?

Here you can use the switch “U” to upgrade an already installed package on the server. One of the major advantages of using this option is that it will not only upgrade the latest version of any package, but it will also maintain the backup of the older package so that in case if the newer upgraded package does not run the previously installed package can be used again.

# rpm -Uvh iftop-1.0-0.pre3.el7.rf.x86_64.rpm
warning: iftop-1.0-0.pre3.el7.rf.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY
Preparing...                          ################################# [100%]
        package iftop-1.0-0.pre3.el7.rf.x86_64 is already installed

Q. How to check dependencies of RPM Package before Installing?

We can use “qpR” combo to list all dependencies of a package. See the example pasted below:

# rpm -qpR iftop-1.0-0.pre3.el7.rf.x86_64.rpm
warning: iftop-1.0-0.pre3.el7.rf.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY
libc.so.6()(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libc.so.6(GLIBC_2.7)(64bit)
libm.so.6()(64bit)
libm.so.6(GLIBC_2.2.5)(64bit)
libncurses.so.5()(64bit)
libpcap.so.1()(64bit)
libpthread.so.0()(64bit)
libpthread.so.0(GLIBC_2.2.5)(64bit)
libpthread.so.0(GLIBC_2.3.2)(64bit)
libtinfo.so.5()(64bit)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rtld(GNU_HASH)
rpmlib(PayloadIsXz) <= 5.2-1

Use the switch “–nodeps” to install a package without its dependencies.

Q. How to Remove a package using rpm command?

The switch “e” is using to erase an installed package from server. The example pasted below will explain this:

# rpm -evv iftop

If you want the dependencies, you can use “–nodeps” while removing a package.
These are the commonly using rpm commands.

Have questions? Click here to submit a support request.

About Albert

Linux server Admin @ TwinBee I am here to help you guys!! Post a comment here if you have any questions. Or go to http://twinbeeservers.com/support.php

Leave a Reply

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

*