Linux中常用壓縮打包工具

2022-09-05 20:27:14 字數 3026 閱讀 8914

壓縮打包是常用的功能,在linux中目前常用的壓縮工具有gzip,bzip2以及後起之秀xz。本文將介紹如下的工具常見壓縮、解壓縮工具以及打包工具tar.

gzip file

壓縮只能壓縮檔案,而不能是目錄;如果需要壓縮目錄,需要加上-r選項

[root@vathe tmp]#ls

test

[root@vathe tmp]#gzip test

[root@vathe tmp]#ls

test.gz

gzip -c file > file.gz

[root@vathe tmp]#ls

test

[root@vathe tmp]#gzip -c test > test.gz

[root@vathe tmp]#ls

test test.gz

gzip -d file.gz

第一種方法

[root@vathe tmp]#ls

test.gz

[root@vathe tmp]#gzip -d test.gz

第二種方法

[root@vathe tmp]#ls

test.gz

[root@vathe tmp]#gunzip test.gz

zcat file.gz

[root@vathe tmp]#zcat test.gz 

[email protected]

bzip file

[root@vathe tmp]#bzip2 test 

[root@vathe tmp]#ls

test.bz2

bzip2 -c file > file.bz2

bzip2 -k file

#方法一

[root@vathe tmp]#bzip2 -vc test > test.bz2

test: 0.122:1, 65.600 bits/byte, -720.00% s**ed, 5 in, 41 out.

#方法二

[root@vathe tmp]#bzip2 -k test

[root@vathe tmp]#ls

test test.bz2

//-v選項是顯示壓縮結果資訊,done表示壓縮成功

bunzip2 file.bz2

bzip2 -d file.bz2

#方法一

[root@vathe tmp]#bunzip2 -v test.bz2

test.bz2: done

#方法二

[root@vathe tmp]#bzip2 -d test.bz2

bzcat file.bz2

[root@vathe tmp]#bzcat test.bz2 

[email protected]

xz file

[root@vathe tmp]#xz test

xz -k file

xz -c file > file.xz

unxz file.xz

xz -d file.xz

xzcat file.xz

compress

compress file   壓縮檔案

compress -c file > file.z 保留原始檔壓縮

compress -d file 解壓縮

zcat file.z 檢視壓縮檔案

gzip

bzip2

xz壓縮檔案預設格式檔案

.gz.bz2

.xz直接壓縮檔案

gzip file

bzip2 file

xz file

保留原始檔壓縮

gzip -c file>file.gz

bzip2 -c file> file.bz2

xz g-k file

解壓縮檔案

gzip -d file.gz

bzip2 -d file.bz2

unxz file.xz

檢視壓縮檔案

zcat file.gz

bzcat file.bz2

xzcat file.xz

注:上面只是列出了對應需求的一種方法,如果全面了解,可詳細檢視部落格。

tar xvf file

tar zcvf dir 以.gz壓縮目錄,並顯示壓縮過程(-v)

tar jcvf dir 以.bz2格式壓縮目錄,並顯示壓縮過程(-v)

Linux壓縮打包工具

一 壓縮與解壓縮 1 gzip和gunzip gzip壓縮 gzip 被壓縮的檔案,gzip 1.txt gunzip解壓 gunzip 壓縮後的gz檔案 gunzip 1.txt.gz 2 bzip2和bunzip2 bzip2壓縮 bzip2 被壓縮的檔案,bzip2 1.txt bunzip2...

壓縮打包工具6 1 6 4

6.1 壓縮打包介紹 6.2 gzip壓縮工具 6.3 bzip2壓縮工具 6.4 xz壓縮工具 壓縮的好處 傳輸省頻寬,儲存省空間 linux 常規壓縮檔案格式.zip,gz,bz2,xz,tar.gz,tar.bz2,tar.xz,雖然之前講過linux系統中的字尾名不代表它的格式,但是對於壓縮...

Linux筆記(壓縮工具zip,tar打包工具)

一 zip壓縮工具 支援壓縮目錄,壓縮檔案和目錄後,原檔案和目錄不刪除 yum install zip y 安裝zip zip 壓縮檔案名 原檔名 壓縮檔案 r 壓縮目錄名 源目錄名 壓縮目錄 yum install unzip y 安裝解壓縮unzip unzip 壓縮檔案 目錄 解壓檔案 因為不...