2024-07-22
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.rpmThe 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.
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 mypackageThe -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 mypackageIf the package is installed, RPM will only display the package name and version. If it’s not installed, you’ll get an error message.
If a newer version of mypackage becomes available, you can upgrade it using:
sudo rpm -Uvh mypackage-1.1-1.rpmThe -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).
To remove mypackage, use:
sudo rpm -e mypackageThe -e option removes the package. Be cautious when removing packages, as it might break dependencies of other applications.
You can list all installed packages using:
rpm -qaThis 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 firefoxThis will list all packages containing “firefox” in their name.
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 -VaThis 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.
RPM maintains a database of installed packages. You can use rpm to interact with this database directly. For example:
rpm -q --whatrequires mypackageThis 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.