Extracting Files from RPM Packages

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.

Exercise 4.5: Extracting Files from RPM Packages

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.

  1. 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.

  2. Use rpm -qf /usr/sbin/modem-manager. This command shows that the file comes from the ModemManager package.

  3. 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.

  4. Change the directory to the /tmp command, and use rpm2cpio |cpio -idmv to extract the package.

  5. 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值