Linux Tutorial

Linux File/Directory Management

Linux Packaging And Compression

Vim Text Editor

Linux Text Processing

Linux Software Installation

Linux User/User Group Management

Linux Permission Management

Linux Filesystem Management

Linux Advanced Filesystem Management

Linux System Management

Linux Backup and Recovery

Linux System Service Management

Linux System Log Management

Linux Boot Management

LAMP/LNMP Environment

SELinux Management

Linux rpm Command

The rpm (Red Hat Package Manager) command in Linux is used to manage software packages on RPM-based distributions such as Red Hat Enterprise Linux, CentOS, and Fedora. In this tutorial, we'll cover the basics of using the rpm command, along with some examples to help you understand its usage.

  • Basic syntax:

The basic syntax for the rpm command is:

rpm [OPTIONS] PACKAGE

Where OPTIONS are the flags or commands used to perform specific actions and PACKAGE is the package file or installed package you want to manage.

  • Common options:
  • -i, --install: Install a package.
  • -e, --erase: Erase (uninstall) a package.
  • -U, --upgrade: Upgrade a package.
  • -V, --verify: Verify a package.
  • -q, --query: Query package information.
  • --import: Import a public key.
  • --resign: Sign a package.
  • -F, --freshen: Upgrade package only if an earlier version is installed.
  • Examples:

a) Installing a package:

To install a package called 'example-package.rpm', run:

rpm -i example-package.rpm

b) Upgrading a package:

To upgrade an existing package with a newer version called 'example-package.rpm', run:

rpm -U example-package.rpm

c) Removing a package:

To remove an installed package called 'example-package', run:

rpm -e example-package

d) Querying package information:

To query information about an installed package, use the -q option:

rpm -q example-package

To query information about a package file, use the -qp option:

rpm -qp example-package.rpm

e) Verifying a package:

To verify the integrity of an installed package, use the -V option:

rpm -V example-package

f) Importing a public key:

To import a public key for package signing, run:

rpm --import /path/to/public-key.gpg

g) Signing a package:

To sign a package with your own key, run:

rpm --resign example-package.rpm

h) Upgrading a package only if an earlier version is installed:

To upgrade a package with 'example-package.rpm' only if an earlier version is already installed, use the -F option:

rpm -F example-package.rpm

For more information and options, refer to the rpm manual by running man rpm or visiting the online documentation. Keep in mind that the rpm command is specific to RPM-based distributions. Other distributions, such as Debian-based systems, use different package managers (e.g., dpkg and apt).

  1. How to use rpm for package management in Linux: The rpm command is used for managing RPM packages on Linux systems. For example, to query information about an installed package:

    rpm -q package_name
    
  2. Installing and removing packages with rpm: To install a package using rpm:

    rpm -i package.rpm
    

    To remove a package:

    rpm -e package_name
    
  3. Querying package information using rpm in Unix-like systems: Use rpm to query package information, such as version, architecture, and installation date. Example:

    rpm -qi package_name
    
  4. Upgrading packages with rpm in Linux: Upgrade a package to a newer version using rpm. Example:

    rpm -U package.rpm
    
  5. Verifying package integrity with rpm: Verify the integrity of installed packages with the -V option. For example:

    rpm -V package_name
    
  6. Advanced options for the rpm command in Linux: Advanced options include using the -F option for upgrading only if the package is newer, and -e --nodeps to remove a package without checking dependencies. Example:

    rpm -F package.rpm
    rpm -e --nodeps package_name
    
  7. Building custom RPM packages in Linux: Create custom RPM packages using the rpmbuild command. Example:

    rpmbuild -bb mypackage.spec
    
  8. Troubleshooting package installations with rpm: Use rpm for troubleshooting, such as checking for dependencies, conflicts, or missing files. Example:

    rpm -Uhv package.rpm