Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How linux uses the tar command to compress large packages into files

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the use of tar command package compression into linux file method. The content is more detailed, the article contains examples of the use of commands, I hope you can gain something from this article.

tar zcvf /data/abc.tgz --exclude=/etc/file1 exclude=/etc/file2 /etc --big package compression etc except file1 and file2 file big package compression file name is abc.tgz equivalent.tar.gz writing is different.

split -b 10M linux-5.1.4.tar.gz linux ---Cut files in 10M size with linux prefix to generate files Split files

split -d -b 10M linux-5.1.4.tar.gz linux.tar.xz ---Split file linux.tar.xz{1.. n} Generate File Split File

[22:51:57 root@localhost data]$split -d -b 20M linux-5.5.4.tar.xz linux-5.tar.xz --split file

[22:53:30 root@localhost data]$ll -h linux-5.* ---Results

-rw-r--r--. 1 root root 106M Feb 19 2020 linux-5.5.4.tar.xz

-rw-r--r--. 1 root root 20M Feb 17 22:53 linux-5.tar.xz00

-rw-r--r--. 1 root root 20M Feb 17 22:53 linux-5.tar.xz01

-rw-r--r--. 1 root root 20M Feb 17 22:53 linux-5.tar.xz02

-rw-r--r--. 1 root root 20M Feb 17 22:53 linux-5.tar.xz03

-rw-r--r--. 1 root root 20M Feb 17 22:53 linux-5.tar.xz04

-rw-r--r--. 1 root root 5.6M Feb 17 22:53 linux-5.tar.xz05

[22:53:39 root@localhost data]$mv linux-5.5.4.tar.xz linux-5.5.4.tar.xz.bak

[22:55:58 root@localhost data]$cat linux-5.tar.xz* > linux-5.tar.xz --merge split files

[22:57:15 root@localhost data]$ll -h linux-5.*

-rw-r--r--. 1 root root 106M Feb 19 2020 linux-5.5.4.tar.xz.bak

-rw-r--r--. 1 root root 106M Feb 17 22:57 linux-5.tar.xz

-rw-r--r--. 1 root root 20M Feb 17 22:53 linux-5.tar.xz00

-rw-r--r--. 1 root root 20M Feb 17 22:53 linux-5.tar.xz01

-rw-r--r--. 1 root root 20M Feb 17 22:53 linux-5.tar.xz02

-rw-r--r--. 1 root root 20M Feb 17 22:53 linux-5.tar.xz03

-rw-r--r--. 1 root root 20M Feb 17 22:53 linux-5.tar.xz04

-rw-r--r--. 1 root root 5.6M Feb 17 22:53 linux-5.tar.xz05

CPIO command is a tool to package and restore files by redirecting them. It can extract files ending in ".cpio" or ".tar"

[23:00:48 root@localhost data]$file initramfs-3.10.0-957.el7.x86_64.img

initramfs-3.10.0-957.el7.x86_64.img: ASCII cpio archive (SVR4 with no CRC)

[23:01:04 root@localhost data]$cpio -tv

< initramfs-3.10.0-957.el7.x86_64.img drwxr-xr-x 3 root root 0 Dec 14 08:30 . drwxr-xr-x 3 root root 0 Dec 14 08:30 kernel drwxr-xr-x 3 root root 0 Dec 14 08:30 kernel/x86 drwxr-xr-x 2 root root 0 Dec 14 08:30 kernel/x86/microcode -rw-r--r-- 1 root root 23552 Dec 14 08:30 kernel/x86/microcode/GenuineIntel.bin -rw-r--r-- 1 root root 2 Dec 14 08:30 early_cpio 48 blocks [23:04:58 root@localhost data]$ [root@centos6 /data]#find | cpio -ov >

/tmp/data.cpio --Find local files and pass them to cpio -o for packaging and display output to/tmp/data.cpio

[root@centos6 /data]#ll -h /tmp/

total 138M

-rw-r--r-- 1 root root 138M Dec 25 14:24 data.cpio

root@centos6 /data]#cpio -tv < /tmp/data.cpio --Preview file

cat /tmp/data.cpio |cpio -tv --preview file

The above is linux using tar command package compression into the file method, after reading whether there is any harvest? If you want to know more about it, welcome to pay attention to industry information!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report