rpm

2024-07-22

Installing Packages with RPM

The most basic use of RPM is installing packages. RPM files usually have a .rpm extension. Let’s say you have a package named mypackage-1.0-1.rpm. To install it, use the following command:

sudo rpm -i mypackage-1.0-1.rpm

The sudo command ensures you have root privileges, which are necessary for installing software. The -i option signifies installation. If the package has dependencies (other packages it relies on), RPM will automatically attempt to install them as well. If a dependency is missing and cannot be found, the installation will fail.

Querying Package Information

Once a package is installed, you can use RPM to obtain information about it. For example, to see detailed information about mypackage, use:

rpm -qi mypackage

The -q option stands for query, and -i specifies that you want detailed information. This will display the package name, version, size, description, and more.

To simply check if a package is installed, use:

rpm -q mypackage

If the package is installed, RPM will only display the package name and version. If it’s not installed, you’ll get an error message.

Upgrading Packages

If a newer version of mypackage becomes available, you can upgrade it using:

sudo rpm -Uvh mypackage-1.1-1.rpm

The -U option stands for upgrade. The -v option enables verbose output, showing the progress of the upgrade. The -h option displays a progress bar (using hashes).

Removing Packages

To remove mypackage, use:

sudo rpm -e mypackage

The -e option removes the package. Be cautious when removing packages, as it might break dependencies of other applications.

Listing Installed Packages

You can list all installed packages using:

rpm -qa

This command lists all packages installed on your system, along with their versions. This is extremely useful for auditing your system’s software. You can pipe the output to grep to filter for specific packages:

rpm -qa | grep firefox

This will list all packages containing “firefox” in their name.

Verifying Package Integrity

RPM allows you to verify the integrity of installed packages to ensure they haven’t been tampered with. This is done using a digital signature:

rpm -Va

This command verifies all installed packages. Any discrepancies will be reported, indicating potential problems. Note that this requires the package to have been installed with a valid digital signature.

Working with RPM Databases

RPM maintains a database of installed packages. You can use rpm to interact with this database directly. For example:

rpm -q --whatrequires mypackage

This command shows which other packages depend on mypackage. This is important before removing a package to avoid breaking dependencies.

These are just some of the many useful commands that rpm provides. Exploring the man rpm page provides a wealth of additional options and functionalities. Properly utilizing rpm is a fundamental skill for efficient Linux system administration.