cpio命令
RPM包中文件提取
cpio命令主要有三種基本模式:"-o"模式指的是copy-out模式,就是把數(shù)據(jù)備份到文件庫中;"-i"模式指的是copy-in模式,就是把數(shù)據(jù)從文件庫中恢復(fù);"-p"模式指的是復(fù)制模式,就是不把數(shù)據(jù)備份到cpio庫中,而是直接復(fù)制為其他文件。
cpio -o[vcB] > [文件|設(shè)備]
-o copy-out模式,備份
-v 顯示備份過程
-c 使用較新的portable format存儲方式
-B 設(shè)定輸入輸出塊為5120bytes,而不是模式的512butes
cpio -i[vcdu] < [文件|設(shè)備]
-i copy-i模式,還原
-v 顯示還原過程
-c 使用較新的portable format存儲方式
-d 還原時自動新建目錄
-u 自動使用較新的文件覆蓋較舊的文件
cpio -p 目標目錄
使用cpio備份數(shù)據(jù)的方法
[root@centos2 ~]# find /etc -print | cpio -ovcB > /root/etc.cpio [root@centos2 ~]# ll -h etc.cpio -rw-r--r-- 1 root root 35M 11月 6 20:18 etc.cpio
恢復(fù)cpio的備份數(shù)據(jù) [root@centos2 ~]# cpio -idvcu < /root/etc.cpio
如果備份時使用絕對路徑,則恢復(fù)的數(shù)據(jù)會直接到絕對路徑指定的路徑中,如果需要把數(shù)據(jù)恢復(fù)到當前目錄中,則需要使用相對路徑
[root@centos2 ~]# cd /etc/ [root@centos2 ~]# find . -print |cpio -ovcB > /root/etc.cpio #進入到,利用find指定要備份/etc/目錄,使用>導(dǎo)出到etc.cpio文件 [root@centos2 ~]# cd /root [root@centos2 ~]# mkdir etc_test [root@centos2 ~]# cd etc_test/ [root@centos2 ~]# cpio -ivdcu < /root/etc.cpio #還原/etc目錄的數(shù)據(jù),因為備份時使用的是相對路徑,則會還原到/root/etc_test/目錄下
cpio -p 復(fù)制模式
[root@centos2 /tmp]# mkdir test [root@centos2 /tmp]# find /boot/ -print | cpio -p /tmp/test [root@centos2 /tmp]# ll test/ 總用量 4 dr-xr-xr-x 5 root root 4096 11月 6 20:31 boot
提取RPM包中文件
rpm2cpio 包全名 | cpio -idv .文件絕對路徑
rpm2cpio 將rpm包轉(zhuǎn)換為cpio格式的命令
cpio
[root@centos2 ~/etc_test]# rpm -qf /etc/inittab initscripts-9.49.47-1.el7.x86_64 [root@centos2 ~/etc_test]# rpm2cpio /mnt/cdrom/ EFI/ images/ isolinux/ LiveOS/ Packages/ repodata/ [root@centos2 ~/etc_test]# rpm2cpio /mnt/cdrom/ EFI/ images/ isolinux/ LiveOS/ Packages/ repodata/ [root@centos2 ~/etc_test]# rpm2cpio /mnt/cdrom/Packages/initscripts-9.49.47-1.el7.x86_64.rpm | cpio -idv ./etc/inittab ./etc/inittab 3046 塊 [root@centos2 ~/etc_test]# ll 總用量 0 drwxr-xr-x 2 root root 21 11月 6 20:48 etc [root@centos2 ~/etc_test]# ll etc/ 總用量 4 -rw-r--r-- 1 root root 511 11月 6 20:48 inittab
總結(jié)
- 上一篇: 预告片场网(最新电影预告片)希望能在今年
- 下一篇: “快手村BA”贵州站直播总观看人次超3亿