"Go" Linux under cpio command use

Source: Internet
Author: User

Transferred from: http://www.51testing.com/html/32/498132-816949.html

Feature Description: Backup files.

Supplemental Note: Cpio is used to create, restore backup files of the tool program, it can be added, to unlock cpio,img or tra backup file within the document.

Type of cpio file:

[[Email protected] test]# file test. Cpio
Test.cpio:ASCII Cpio Archive (SVR4 with no CRC)

Cpio Example Explanation

1. Common operation mode

(1) Backup: CPIO-OCVB > [File | device]
(2) Restore: cpio-ivcdu >
[File | device]
(3) Views: cpio-ivct >[file | device]

2. Relevant examples

1) cpio-out mode

(1) Find out all the files in the current directory and pack them into a cpio zip package file
Find. -depth | CPIO-OCVB > Backup.cpio or Find-depth-print | CPIO-OCVB > Backup.cpio
Note: The archive file created by Cpio includes both the file header and the File Data section. The file header contains information about the corresponding file. such as file Uid,gid, number of connections and file size. The benefit is that a hard connection can be preserved, the time stamp is preserved by default on recovery, and there is no limit on file name length

(2) Add the current directory named Inittab file to the Initrd.cpio package
Command 1:find. -name inittab-depth | Cpio-ovcb-a-F Initrd.cpio
Command 2:find. -name inittab-depth | Cpio-ovcb-a-O Initrd.cpio
Command 3:find. -name inittab-depth | Cpio-ovcb-a--quiet-o Initrd.cpio (--quit: Indicates that the copy block is not displayed)

Cpio--ABSOLUTE-FILENAMES-VTC < Boot.cpio (not ignoring the "/" in front of file name list)
Cpio--NO-ABSOLUTE-FILENAMES-VTC < Boot.cpio (default is the one in the file that ignores the file list List

(2) Extracting files from the Cpio compressed package
Cpio--ABSOLUTE-FILENAMES-ICVU < Test.cpio (Unzip to original location, extract the time attribute of each file to the current time)
Cpio--absolute-filenames-icvum < Test.cpio (unzip to original position without changing the time attribute of each file extracted)

CPIO-ICVU < Test.cpio (unzip to current directory) or Cpio-icvum < Test.cpio

(3) When unpacking the Cpio, the name of the interaction of the unpacked file
Cpio-icvdu-r < Grub.cpio

(4) Extract the files from the Cpio package and enter the standard output
CPIO-ICVU--to-stdout < Grub.cpio
Note: Since the standard output is extracted, you cannot use the-d parameter

3) Cpio-out mode

(1) Copying files and changing the owner and genus of the files
Find. -depth| Cpio-r ruanxi:ruanxi-pl/backup/

4) Analysis of the system directory/boot initrd-2.6.30.9.img file
[Email protected] tmp]# file/boot/initrd-2.6.30.9.img
/boot/initrd-2.6.30.9.img:gzip compressed data, from Unix, last Modified:fri Nov 22:12:38, max compression
#由上面可知道, initrd-2.6.30.9.img It's a gzip file
-------------------------------------------------------------------
[Email protected] tmp]# cp/boot/initrd-2.6.30.9.img./initrd.img.gz
[Email protected] tmp]# gzip-d initrd.img.gz
#通过gzip指令解压出文件
-------------------------------------------------------------------
[[Email protected] tmp]# file initrd.img
Initrd.img:ASCII Cpio Archive (SVR4 with no CRC)
#可知解压出的文件是一个cpio压缩包
[Email protected] tmp]# CPIO-IVCDU < initrd.img
#最后再使用cpio指令解包

"Go" Linux under cpio command use

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.