cpio
압축·전송
쓰는 꼴
find <path> | cpio -o > <archive.cpio>무엇을 담을지 표준입력으로 받은 이름 목록에서 정하는 옛 묶음 도구라, 그 목록은 대개 find가 만듭니다 — `-o`가 묶기, `-i`가 풀기, `-t`가 목록이고, initramfs가 쓰는 꼴은 `-H newc`이며, 남이 준 묶음은 절대경로로 튀어나오지 않게 `--no-absolute-filenames`를 붙입니다.
자주 쓰는 옵션
| 옵션 | 뜻 |
|---|---|
| -o | Copy-out: build an archive from the names arriving on stdin. |
| -i | Copy-in: extract from an archive on stdin. |
| -d | Create directories as needed while extracting. |
| -m | Preserve modification times. |
| -t | List the contents instead of extracting. |
| -v | Print names as they are processed. |
| -H newc | The portable SVR4 format, and the one initramfs images use. |
| --no-absolute-filenames | Refuse to extract to absolute paths from an untrusted archive (GNU cpio only). |
예시
find . -depth -print | cpio -ov -H newc > backup.cpioArchive exactly the file list that find produced.
cpio -idmv < backup.cpioExtract, creating directories and keeping timestamps.
cpio -itv < backup.cpioList what is inside first.
압축과 묶음은 다른 일입니다. tar가 묶고 gzip이 줄이며, .tar.gz는 그 둘을 겹친 것입니다.
읽는 방법
- 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
- 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
- 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.
자주 묻는 것
Q. cpio은 무엇을 하나요?
무엇을 담을지 표준입력으로 받은 이름 목록에서 정하는 옛 묶음 도구라, 그 목록은 대개 find가 만듭니다 — `-o`가 묶기, `-i`가 풀기, `-t`가 목록이고, initramfs가 쓰는 꼴은 `-H newc`이며, 남이 준 묶음은 절대경로로 튀어나오지 않게 `--no-absolute-filenames`를 붙입니다.
Q. 어떻게 치나요?
find <path> | cpio -o > <archive.cpio> — 대괄호는 생략할 수 있는 자리입니다.
Q. 옵션은 몇 개나 자주 쓰나요?
여기 정리한 것은 8개입니다. 전체 목록은 man cpio에 있습니다. 이 명령은 압축·전송 갈래입니다.
같이 보는 명령
man 페이지: man cpio