Extracting Files from RPM Packages
Software installed on your computer may become damaged. If this happens, it's good to know that you can extract files from the packages and copy them to the original location of the file.
Every RPM package consists of two parts: the metadata part that describes what is in the package and a cpio archive that contains the actual files in the package. If a file has been damaged, you can start with the rpm -qf query option to find out from what package the file originated. Next use rpm2cpio | cpio -idmv to extract the files from the package to a temporary location. In Exercise 4.5, you'll learn how to do this.
In this exercise, you'll learn how to identify from which package a file originated. Next you'll extract the package to the /tmp directory, which allows you to copy the original file from the extracted RPM to the location where it's supposed to exist.
-
Use rm -f /usr/sbin/modem-manager. Oops! You've just deleted a file from your system! (It normally doesn't do any harm to delete modem-manager, because it's hardly ever used anymore.
-
Use rpm -qf /usr/sbin/modem-manager. This command shows that the file comes from the ModemManager package.
-
Copy the ModemManager package file from the repository you created in Exercise 4.1 to the /tmp directory by using the cp /repo/ModemM[Tab] /tmp command.
-
Change the directory to the /tmp command, and use rpm2cpio |cpio -idmv to extract the package.
-
The command you used in step 4 created a few subdirectories in /tmp. Activate the directory /tmp/usr/sbin, where you can find the modem-manager file. You can now copy it to its original location in /usr/sbin.