Updating rpm packages linux

15+ rpm command examples in Linux [Cheat Sheet]

RPM (Red Hat Package Manager) is an open-source package management tool in RHEL based systems such as RHEL, CentOS, and Fedora. You can install, update, remove, or verify RPM packages with this tool. RPM only works with .rpm files, so you need to have a .rpm file in your system. The .rpm file stores the installation packages of RPM-based Linux distribution.

Different examples to use rpm command

Since you will need to have .rpm files, you can download them from here. You can also use the dnf command to download the rpm package using this command.

$ sudo dnf install package_name --downloadonly --downloaddir=DIR_PATH

You can find our detailed article on dnf at 25+ DNF command practical examples in Linux.

In this article, we will learn how to use rpm commands to manage the RPM packages on the system.

1. rpm command to install an RPM package

You can use -i or —install option to install an RPM package on your system. The RPM package must be available in your workstation.

$ sudo rpm --install rpm_filename

Sample Output:

In the following example, we are installing single rpm. If this rpm has any dependency over other rpm then that must be manually handled by downloading that rpm and installing them both together or else the installation will fail with dependency error.

rpm command to install rpm package

  • -v: To display the verbose output
  • -h: To print the hash symbol progress bar

2. Check an installed RPM package with rpm command

You can use -q option to check whether an RPM package is installed in your system or not.

Sample Output:

check an installed rpm package with rpm commnd

As you can see, iotop is installed in our system. The package name that you provide may be incorrect, so you can also try the following command

$ sudo rpm -qa | grep package_name

This command can also help you check if the provided package is installed or not.

Читайте также:  Linux для android планшетов

3. rpm command to upgrade an RPM package

-U or —upgrade option allows you to upgrade any RPM package to the latest version. This is the same as install, except all other version(s) of the package are removed after the new package is installed.

$ sudo rpm --upgrade rpm_filename

Sample Output:

rpm command to update package

4. Remove an RPM package with rpm command

You can remove an installed package from your system with -e or —erase option.

$ sudo rpm --erase package_name

Sample Output:

rpm command to remove installed package

In some cases, this command fails to remove the package from the system due to unresolved dependencies. So, the best way to remove RPM packages and their dependencies is by using yum or dnf command.

rpm command to remove rpm package

5. Check dependencies of an RPM package using rpm command

This command allows you to check the dependencies of an RPM package on the system.

$ sudo rpm -qpR rpm_filename

Sample Output:

rpm command to check dependencies

  • -q: To query an RPM package
  • -p: To query an uninstalled package
  • -R: To list capabilities on which the package depends

6. rpm command to print the information of an RPM package

With the help of this command, you can get the information of an RPM package on your system.

$ sudo rpm -qip rpm_filename

Sample Output:

rpm command to print information of rpm package

7. rpm command to get information of an installed package

Sometimes, you may want to get the information of any installed packages on the system. In that case, you can use this command.

Sample Output:

rpm command to get information of installed package

8. Install an RPM package without dependencies with rpm command

—nodeps option allows you to install an RPM package without dependencies. It ignores the dependencies errors and forcefully installs an RPM package. Some programs may not work until you install the required dependencies.

$ sudo rpm -ivh --nodeps rpm_filename

Sample Output:

rpm command to install pckage without dependencies

This is strictly not recommended as this can potentially break your system for more complex rpms such as kernel, gcc etc.

9. rpm command to list all files of an installed RPM package

You can use this command to list all the files of an installed RPM package.

Sample Output:

rpm command to list all files of installed package

10. Remove an RPM package without dependencies using rpm command

You can also use —nodeps option with the erase command to uninstall an RPM package without checking dependencies. It ignores all the dependencies errors and forcefully removes the package.

$ sudo rpm -ev --nodeps package_name

Sample Output:

rpm command to remove package without dependencies

Now, let’s check if the package is removed.

rpm nodeps command

The package is removed, but the dependencies are still present in the system.

This is strictly not recommended as this can potentially break your system for more complex rpms such as kernel, gcc.

11. List all installed RPM packages with rpm command

To view the list of all installed RPM packages in your system, you can use this command.

Sample Output:

rpm command to list all installed packages

12. List only recently installed RPM packages with rpm command

You can use this command to view the list of recently installed RPM packages on your system.

Читайте также:  Linux program running window

Sample Output:

rpm command to list recently installed packages

13. Verify an RPM package with rpm command

-V or —verify option allows you to verify an RPM package against the rpm database. It compares the installed package information with package metadata stored in the rpm database. It also compares the size, digest, permissions, type, owner, and group of each file.

$ sudo rpm --verify -p rpm_filename

Sample Output:

rpm command to verify rpm paackage

14. rpm command to verify all RPM packages

You can use this command to verify all RPM packages.

Sample Output:

rpm command to verify all packages

15. Query a file with rpm command

You can also query a file and find to which RPM package it belongs.

$ sudo rpm -qf [file_name or file_path]

Sample Output:

rpm command to query file

16. rpm command to check signatures in an RPM package

—checksig option checks all the digests and signatures contained in an RPM package file. It is a useful command to verify the integrity and origin of the package is ok.

$ sudo rpm --checksig rpm_filename

Sample Output:

rpm command to check signatures

17. Import an RPM GPG key with rpm command

You can import a GPG key with —import option. RPM GPG key files are located in the /etc/pki/rpm-gpg directory.

$ sudo rpm --import RPM-GPG-KEY_File

Sample Output:

rpm command to import gpg key

You can list all imported GPG keys with the following command.

Sample Output:

rpm command to list all imported gpg keys

Conclusion

This article shows you the practical examples of rpm command on RPM-based Linux distribution. rpm is a powerful package manager tool to install, remove, update, query, and verify RPM packages. We hope that you can now manage the RPM packages using rpm command. If you have any questions, you can use the comment section below.

Источник

Linux package management with YUM and RPM

Gift package wrapped in purple with lavender ribbon

Installing, patching, and removing software packages on Linux machines is one of the common tasks every sysadmin has to do. Here is how to get started with Linux package management in Linux Red Hat-based distributions (distros).

Package management is a method of installing, updating, removing, and keeping track of software updates from specific repositories (repos) in the Linux system. Linux distros often use different package management tools. Red Hat-based distros use RPM (RPM Package Manager) and YUM/DNF (Yellow Dog Updater, Modified/Dandified YUM).

Yellow Dog Updater, Modified (YUM)

[ Editor’s Note: DNF or Dandified YUM is the updated default since Red Hat Enterprise Linux 8, CentOS 8, Fedora 22, and any distros based on these. Generally, the options are the same. Read more about DNF here. ]

YUM is the primary package management tool for installing, updating, removing, and managing software packages in Red Hat Enterprise Linux. YUM performs dependency resolution when installing, updating, and removing software packages. YUM can manage packages from installed repositories in the system or from .rpm packages. The main configuration file for YUM is at /etc/yum.conf , and all the repos are at /etc/yum.repos.d .

You can learn more about adding repositories to your system from this article on how to add a YUM repo from Amy Marrich.

It’s easy to manage packages in Linux with YUM . At the command line, enter:

Читайте также:  Linux зачем нужен загрузчик grub

There are many options and commands available to use with YUM . I’ve listed some commonly-used commands for YUM below:

Command Purpose
yum install Installs the specified packages
remove Removes the specified packages
search Searches package metadata for keywords
info Lists description
update Updates each package to the latest version
repolist Lists repositories
history Displays what has happened in past transactions

The following are commonly-used options with YUM :

Options Purpose
-C Runs from system cache
—security Includes packages that provide a fix for a security issue
-y Answers yes to all questions
—skip-broken Skips packages causing problems
-v Verbose

The history option gives you an overview of what happened in past transactions. This provides some useful information, like the date when the transaction happened and what command was run.

yum-history

You can undo or redo certain transactions using the history command. Here is an example of undoing a transaction:

YUM provides many options for package management. For detailed option information, look at man yum and yum –help . Also, here is a link to YUM documentation.

RPM is a popular package management tool in Red Hat Enterprise Linux-based distros. Using RPM , you can install, uninstall, and query individual software packages. Still, it cannot manage dependency resolution like YUM . RPM does provide you useful output, including a list of required packages. An RPM package consists of an archive of files and metadata. Metadata includes helper scripts, file attributes, and information about packages.

RPM maintains a database of installed packages, which enables powerful and fast queries. The RPM database is inside /var/lib , and the file is named __db* .

RPM has some basic modes: query, verify, install, upgrade, erase, show querytags, show configuration. At least one of these modes needs to be selected to perform package management tasks. Every mode has its own set of options. For example, install mode i has its own set of installation options. Options for the modes are found on the RPM man pages at man rpm .

Some commonly-used modes are listed below:

Mode Description
-i Installs a package
-U Upgrades a package
-e Erases a package
-V Verifies a package
-q Queries a package

Here are some commonly-used general options:

General options Purpose
-? | —help Prints help
—version Prints version number
-v Prints verbose output

To install or upgrade an .rpm package using RPM, issue this command:

The flag -i is for install, U is for upgrade, v for verbose, h for hash (this option displays the # as a progress bar for the operation). In this example, v and h are optional flags.

rpm-ivh

To query for a package using RPM issue following command:

rpm -q query-options package

Option a queries all installed packages on the system.

rpm-qa

To erase a package, use the following command:

rpm -e erase-options package-name

rpm-evh

Package management is a common task for every system. YUM and RPM provide efficient ways to install, upgrade, remove, and track software packages on Red Hat Enterprise Linux systems.

[ Want to try out Red Hat Enterprise Linux? Download it now for free. ]

Источник

Оцените статью
Adblock
detector