Friday, May 6, 2016

Basic Package Management With RPM command

Basic Package Management With RPM command



The RPM Package Manager (RPM) is a powerful command line driven package management system capable of installing, uninstalling, verifying, querying, and updating software packages for RPM based Linux Distros. This is adopted by many Linux Distros such as Red Hat Enterprise Linux, Fedora , SUSE Linux, openSUSE, CentOS, Meego, Mageia and many others.
It is also used on many other operating systems as well, and the RPM format is part of the Linux Standard Base .

Working with the rpm command

The rpm command performs the most common package-management functions, along with a host of uncommon functions as well. The table below lists the main operations you can perform with the rpm command and the command-line options to specify the given operations.

rpm command operations :

OperationShort OptionLong Option
Upgrade/install-U--upgrade
Install-i--install
Remove-e--erase
Query-q--query
Verify-V--verify
Check signature-K--checksig
Freshen (upgrade) already-installed package-F--freshen
Initialize databaseNone--initdb
Rebuild databaseNone--rebuilddb

Using this table as a guide, you can explore the options to the rpm command. To install or upgrade a package, use the -U command-line option:

rpm -U filename.rpm

Or , You can also use rpm -i filename.rpm for installation but you can use rpm -U filename.rpm for both installation and Upgrading purpose.

Please note that you need to log in as root, or use the su command to change to the root user to install the software using rpm command:

For example, to install the mlocate RPM used as an example in this chapter, run the following command:

rpm -U mlocate-0.22.2-2.i686.rpm

To get extra feedback, you can use a command like the following, with the -h and -v options in conjunction with the -U option:

rpm -Uhv mlocate-0.22.2-2.i686.rpm

When you run this command you will see more output than the default, which is no output unless there are errors. With the -h option, the rpm command will print a series of hash marks, #, to provide feedback that the command is still running. With the -v option, the rpm command provides more verbose messages.

To remove a package (called erase in RPM terminology), use the -e command-line option:

rpm -e package_name
Notice that you install a package file using the file name that ends in .rpm, but uninstall or erase a package without the .rpm extension. This is because you install RPM files, but once installed, you work with the installed packages. The file name and the package name do not have to correspond, but typically (and sanely) they have the same base name.

To list every RPM package installed on your system, use a command like the following.

rpm -qa

Expect to wait while this command completes. Most Linux systems have numerous packages installed, which will result in many lines of output. To better see the output, you can pipe this command to the more command, as shown following:

rpm -qa | more

You will then see the package listing one screen at a time.


Blog Archive