zip命令能夠用來解壓縮文件,或者對文件進行打包操做。zip是個使用普遍的壓縮程序,文件經它壓縮後會另外產生具備「.zip」擴展名的壓縮文件。linux
注意: zip既能夠壓縮目錄文件也能夠壓縮普通文件。數組
語法: zip [options] [file name.zip] [file name]工具
說明: zip後面先跟目標文件名,也就是自定義的壓縮包名,而後跟源文件名。spa
options:unix
-r:壓縮目錄文件時使用,表示級聯壓縮,連通目錄內文件一同壓縮code
[root@cham3 d6z]# yum install -y zip
壓縮普通文件ip
[root@cham3 d6z]# zip 1.txt.zip 1.txt adding: 1.txt (deflated 73%) [root@cham3 d6z]# du -sh 1.txt.zip 548K 1.txt.zip [root@cham3 d6z]# ls 1.txt 1.txt.zip 2 2.txt 2.txt.gz 2.txt.zip 3.txt 4.txt chamlinux
說明: 使用zip壓縮文件時,源文件不會被刪除。io
壓縮目錄文件test
[root@cham3 d6z]# du -sh chamlinux 8.0M chamlinux [root@cham3 d6z]# zip -r cham.zip 3.txt chamlinux adding: 3.txt (deflated 73%) adding: chamlinux/ (stored 0%) adding: chamlinux/2/ (stored 0%) adding: chamlinux/2/4.txt (deflated 73%) adding: chamlinux/tmp/ (stored 0%) adding: chamlinux/tmp/.ICE-unix/ (stored 0%) adding: chamlinux/tmp/.X11-unix/ (stored 0%) adding: chamlinux/tmp/.Test-unix/ (stored 0%) adding: chamlinux/tmp/.XIM-unix/ (stored 0%) adding: chamlinux/tmp/.font-unix/ (stored 0%) adding: chamlinux/tmp/1.txt (deflated 57%) adding: chamlinux/tmp/chamlinux/ (stored 0%) adding: chamlinux/tmp/chamlinux/2/ (stored 0%) adding: chamlinux/tmp/cham/ (stored 0%) adding: chamlinux/tmp/cham/chamlinux/ (stored 0%) adding: chamlinux/tmp/cham/chamlinux/2/ (stored 0%) adding: chamlinux/tmp/cham1/ (stored 0%) adding: chamlinux/tmp/cham1/2/ (stored 0%) adding: chamlinux/tmp/cham1/chamlinux/ (stored 0%) adding: chamlinux/tmp/cham1/chamlinux/2/ (stored 0%) adding: chamlinux/tmp/.ch (stored 0%) adding: chamlinux/tmp/ch.log (stored 0%) adding: chamlinux/tmp/88.txt (stored 0%) adding: chamlinux/tmp/ping/ (stored 0%) adding: chamlinux/tmp/ping/88.txt (deflated 2%) adding: chamlinux/tmp/.99.txt (stored 0%) adding: chamlinux/tmp/d6z/ (stored 0%) adding: chamlinux/tmp/d6z/2.txt.gz (stored 0%) adding: chamlinux/tmp/d6z/3.txt (deflated 73%) adding: chamlinux/tmp/d6z/1.txt (deflated 73%) adding: chamlinux/tmp/d6z/4.txt (deflated 73%) adding: chamlinux/tmp/d6z/chamlinux/ (stored 0%) adding: chamlinux/tmp/d6z/chamlinux/2/ (stored 0%) [root@cham3 d6z]# ls 1.txt 1.txt.zip 2 2.txt 2.txt.gz 2.txt.zip 3.txt 4.txt chamlinux cham.zip [root@cham3 d6z]# du -sh cham.zip 2.7M cham.zip
解壓縮(須要安裝unzip)可視化
[root@cham3 d6z]# yum install -y unzip
[root@cham3 d6z]# unzip cham.zip Archive: cham.zip replace 3.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y inflating: 3.txt replace chamlinux/2/4.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y inflating: chamlinux/2/4.txt replace chamlinux/tmp/1.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: A inflating: chamlinux/tmp/1.txt extracting: chamlinux/tmp/.ch extracting: chamlinux/tmp/ch.log extracting: chamlinux/tmp/88.txt inflating: chamlinux/tmp/ping/88.txt extracting: chamlinux/tmp/.99.txt extracting: chamlinux/tmp/d6z/2.txt.gz inflating: chamlinux/tmp/d6z/3.txt inflating: chamlinux/tmp/d6z/1.txt inflating: chamlinux/tmp/d6z/4.txt [root@cham3 d6z]# ls 1.txt 1.txt.zip 2 2.txt 2.txt.gz 2.txt.zip 3.txt 4.txt chamlinux cham.zip
說明: 因zip壓縮文件時不刪除源文件,因此在相同目錄進行解壓縮時會提示:‘replace 1.txt? ’。
2
[root@cham3 d6z]# mkdir test [root@cham3 d6z]# unzip 1.txt.zip -d test/ Archive: 1.txt.zip inflating: test/1.txt
說明: 解壓時能夠指定目錄,可是不能指定其解壓後的文件名。
查看壓縮文件
[root@cham3 d6z]# unzip -l cham.zip Archive: cham.zip Length Date Time Name --------- ---------- ----- ---- 2086279 11-09-2017 11:41 3.txt 0 11-09-2017 21:07 chamlinux/ 0 11-09-2017 21:10 chamlinux/2/ 2086279 11-09-2017 21:10 chamlinux/2/4.txt 0 11-09-2017 21:04 chamlinux/tmp/ 0 11-09-2017 21:04 chamlinux/tmp/.ICE-unix/ 0 11-09-2017 21:04 chamlinux/tmp/.X11-unix/ 0 11-09-2017 21:04 chamlinux/tmp/.Test-unix/ 0 11-09-2017 21:04 chamlinux/tmp/.XIM-unix/ 0 11-09-2017 21:04 chamlinux/tmp/.font-unix/ 1053 11-09-2017 21:04 chamlinux/tmp/1.txt 0 11-09-2017 21:04 chamlinux/tmp/chamlinux/ 0 11-09-2017 21:04 chamlinux/tmp/chamlinux/2/ 0 11-09-2017 21:04 chamlinux/tmp/cham/ 0 11-09-2017 21:04 chamlinux/tmp/cham/chamlinux/ 0 11-09-2017 21:04 chamlinux/tmp/cham/chamlinux/2/ 0 11-09-2017 21:04 chamlinux/tmp/cham1/ 0 11-09-2017 21:04 chamlinux/tmp/cham1/2/ 0 11-09-2017 21:04 chamlinux/tmp/cham1/chamlinux/ 0 11-09-2017 21:04 chamlinux/tmp/cham1/chamlinux/2/ 0 11-09-2017 21:04 chamlinux/tmp/.ch 3 11-09-2017 21:04 chamlinux/tmp/ch.log 7 11-09-2017 21:04 chamlinux/tmp/88.txt 0 11-09-2017 21:04 chamlinux/tmp/ping/ 41 11-09-2017 21:04 chamlinux/tmp/ping/88.txt 10 11-09-2017 21:04 chamlinux/tmp/.99.txt 0 11-09-2017 21:04 chamlinux/tmp/d6z/ 35 11-09-2017 21:04 chamlinux/tmp/d6z/2.txt.gz 2086279 11-09-2017 21:04 chamlinux/tmp/d6z/3.txt 2086279 11-09-2017 21:04 chamlinux/tmp/d6z/1.txt 2086279 11-09-2017 21:04 chamlinux/tmp/d6z/4.txt 0 11-09-2017 21:04 chamlinux/tmp/d6z/chamlinux/ 0 11-09-2017 21:04 chamlinux/tmp/d6z/chamlinux/2/ --------- ------- 10432544 33 files [root@cham3 d6z]#
說明: zip壓縮文件只能使用‘unzip -l’查看其文件目錄,沒法查看文件內容
tar命令是Unix/Linux系統中備份文件的可靠方法,幾乎能夠工做於任何環境中,它的使用權限是全部用戶。
語法: tar [options] [filename]
options:
-c:創建一個tar包或者壓縮文件包
-f:指定目標文件名,若是多個參數組合使用時,把-f放在最後面
-z:同時用gzip壓縮
-j:同時用bzip2壓縮
-J:同時用xz壓縮
-t:查看包裏面的文件 -v:可視化
--exclude:後面跟文件名,表示打包除了該文件以外的內容
打包目錄文件
[root@cham3 d6z]# tar -cvf chamlinux.tar chamlinux/ chamlinux/ chamlinux/2/ chamlinux/2/4.txt chamlinux/tmp/ chamlinux/tmp/.ICE-unix/ chamlinux/tmp/.X11-unix/ chamlinux/tmp/.Test-unix/ chamlinux/tmp/.XIM-unix/ chamlinux/tmp/.font-unix/ chamlinux/tmp/chamlinux/ chamlinux/tmp/chamlinux/2/ chamlinux/tmp/cham/ chamlinux/tmp/cham/chamlinux/ chamlinux/tmp/cham/chamlinux/2/ chamlinux/tmp/cham1/ chamlinux/tmp/cham1/2/ chamlinux/tmp/cham1/chamlinux/ chamlinux/tmp/cham1/chamlinux/2/ chamlinux/tmp/ping/ chamlinux/tmp/ping/88.txt chamlinux/tmp/d6z/ chamlinux/tmp/d6z/chamlinux/ chamlinux/tmp/d6z/chamlinux/2/ chamlinux/tmp/d6z/2.txt.gz chamlinux/tmp/d6z/3.txt chamlinux/tmp/d6z/1.txt chamlinux/tmp/d6z/4.txt chamlinux/tmp/1.txt chamlinux/tmp/.ch chamlinux/tmp/ch.log chamlinux/tmp/88.txt chamlinux/tmp/.99.txt [root@cham3 d6z]# ls 1.txt 1.txt.zip 2 2.txt 2.txt.gz 2.txt.zip 3.txt 4.txt chamlinux chamlinux.tar cham.zip test [root@cham3 d6z]# tar -cf chamlinux.tar chamlinux/ [root@cham3 d6z]# ls 1.txt 1.txt.zip 2 2.txt 2.txt.gz 2.txt.zip 3.txt 4.txt chamlinux chamlinux.tar cham.zip test
說明: 打包不會刪除源文件,當某.tar文件已經存在時,再次打包會直接覆蓋該文件,無任何提示。
打包普通文件
[root@cham3 d6z]# tar -cvf 2.tar 2.txt 2.txt [root@cham3 d6z]# ls 1.txt 1.txt.zip 2 2.tar 2.txt 2.txt.gz 2.txt.zip 3.txt 4.txt chamlinux chamlinux.tar cham.zip test [root@cham3 d6z]# du -sh 2.tar 12K 2.tar
同時打包目錄文件和普通文件
[root@cham3 d6z]# tar -cvf chamlinux.tar chamlinux 3.txt 4.txt chamlinux/ chamlinux/2/ chamlinux/2/4.txt chamlinux/tmp/ chamlinux/tmp/.ICE-unix/ chamlinux/tmp/.X11-unix/ chamlinux/tmp/.Test-unix/ chamlinux/tmp/.XIM-unix/ chamlinux/tmp/.font-unix/ chamlinux/tmp/chamlinux/ chamlinux/tmp/chamlinux/2/ chamlinux/tmp/cham/ chamlinux/tmp/cham/chamlinux/ chamlinux/tmp/cham/chamlinux/2/ chamlinux/tmp/cham1/ chamlinux/tmp/cham1/2/ chamlinux/tmp/cham1/chamlinux/ chamlinux/tmp/cham1/chamlinux/2/ chamlinux/tmp/ping/ chamlinux/tmp/ping/88.txt chamlinux/tmp/d6z/ chamlinux/tmp/d6z/chamlinux/ chamlinux/tmp/d6z/chamlinux/2/ chamlinux/tmp/d6z/2.txt.gz chamlinux/tmp/d6z/3.txt chamlinux/tmp/d6z/1.txt chamlinux/tmp/d6z/4.txt chamlinux/tmp/1.txt chamlinux/tmp/.ch chamlinux/tmp/ch.log chamlinux/tmp/88.txt chamlinux/tmp/.99.txt 3.txt 4.txt [root@cham3 d6z]# du -sh chamlinux.tar 12M chamlinux.tar [root@cham3 d6z]# ls 1.txt 1.txt.zip 2 2.txt 2.txt.gz 2.txt.zip 3.txt 4.txt chamlinux chamlinux.tar cham.zip test
[root@cham3 d6z]# tar -tf chamlinux.tar chamlinux/ chamlinux/2/ chamlinux/2/4.txt chamlinux/tmp/ chamlinux/tmp/.ICE-unix/ chamlinux/tmp/.X11-unix/ chamlinux/tmp/.Test-unix/ chamlinux/tmp/.XIM-unix/ chamlinux/tmp/.font-unix/ chamlinux/tmp/chamlinux/ chamlinux/tmp/chamlinux/2/ chamlinux/tmp/cham/ chamlinux/tmp/cham/chamlinux/ chamlinux/tmp/cham/chamlinux/2/ chamlinux/tmp/cham1/ chamlinux/tmp/cham1/2/ chamlinux/tmp/cham1/chamlinux/ chamlinux/tmp/cham1/chamlinux/2/ chamlinux/tmp/ping/ chamlinux/tmp/ping/88.txt chamlinux/tmp/d6z/ chamlinux/tmp/d6z/chamlinux/ chamlinux/tmp/d6z/chamlinux/2/ chamlinux/tmp/d6z/2.txt.gz chamlinux/tmp/d6z/3.txt chamlinux/tmp/d6z/1.txt chamlinux/tmp/d6z/4.txt chamlinux/tmp/1.txt chamlinux/tmp/.ch chamlinux/tmp/ch.log chamlinux/tmp/88.txt chamlinux/tmp/.99.txt 3.txt 4.txt
[root@cham3 d6z]# tar -cvf chamlinux.tar --exclude 2 chamlinux 3.txt 4.txt 打包除了目錄2之外的文件 chamlinux/ chamlinux/tmp/ chamlinux/tmp/.ICE-unix/ chamlinux/tmp/.X11-unix/ chamlinux/tmp/.Test-unix/ chamlinux/tmp/.XIM-unix/ chamlinux/tmp/.font-unix/ chamlinux/tmp/chamlinux/ chamlinux/tmp/cham/ chamlinux/tmp/cham/chamlinux/ chamlinux/tmp/cham1/ chamlinux/tmp/cham1/chamlinux/ chamlinux/tmp/ping/ chamlinux/tmp/ping/88.txt chamlinux/tmp/d6z/ chamlinux/tmp/d6z/chamlinux/ chamlinux/tmp/d6z/2.txt.gz chamlinux/tmp/d6z/3.txt chamlinux/tmp/d6z/1.txt chamlinux/tmp/d6z/4.txt chamlinux/tmp/1.txt chamlinux/tmp/.ch chamlinux/tmp/ch.log chamlinux/tmp/88.txt chamlinux/tmp/.99.txt 3.txt 4.txt [root@cham3 d6z]# tar -cvf chamlinux.tar --exclude 2 --exclude 1.txt chamlinux 3.txt 4.txt 打包除了目錄2 和 1.txt之外的文件 chamlinux/ chamlinux/tmp/ chamlinux/tmp/.ICE-unix/ chamlinux/tmp/.X11-unix/ chamlinux/tmp/.Test-unix/ chamlinux/tmp/.XIM-unix/ chamlinux/tmp/.font-unix/ chamlinux/tmp/chamlinux/ chamlinux/tmp/cham/ chamlinux/tmp/cham/chamlinux/ chamlinux/tmp/cham1/ chamlinux/tmp/cham1/chamlinux/ chamlinux/tmp/ping/ chamlinux/tmp/ping/88.txt chamlinux/tmp/d6z/ chamlinux/tmp/d6z/chamlinux/ chamlinux/tmp/d6z/2.txt.gz chamlinux/tmp/d6z/3.txt chamlinux/tmp/d6z/4.txt chamlinux/tmp/.ch chamlinux/tmp/ch.log chamlinux/tmp/88.txt chamlinux/tmp/.99.txt 3.txt 4.txt [root@cham3 d6z]# tar -cvf chamlinux.tar --exclude "*.txt" chamlinux 3.txt 4.txt 打包除了「.txt」之外的文件 chamlinux/ chamlinux/2/ chamlinux/tmp/ chamlinux/tmp/.ICE-unix/ chamlinux/tmp/.X11-unix/ chamlinux/tmp/.Test-unix/ chamlinux/tmp/.XIM-unix/ chamlinux/tmp/.font-unix/ chamlinux/tmp/chamlinux/ chamlinux/tmp/chamlinux/2/ chamlinux/tmp/cham/ chamlinux/tmp/cham/chamlinux/ chamlinux/tmp/cham/chamlinux/2/ chamlinux/tmp/cham1/ chamlinux/tmp/cham1/2/ chamlinux/tmp/cham1/chamlinux/ chamlinux/tmp/cham1/chamlinux/2/ chamlinux/tmp/ping/ chamlinux/tmp/d6z/ chamlinux/tmp/d6z/chamlinux/ chamlinux/tmp/d6z/chamlinux/2/ chamlinux/tmp/d6z/2.txt.gz chamlinux/tmp/.ch chamlinux/tmp/ch.log
[root@cham3 d6z]# tar xvf chamlinux.tar chamlinux/ chamlinux/2/ chamlinux/2/4.txt chamlinux/tmp/ chamlinux/tmp/.ICE-unix/ chamlinux/tmp/.X11-unix/ chamlinux/tmp/.Test-unix/ chamlinux/tmp/.XIM-unix/ chamlinux/tmp/.font-unix/ chamlinux/tmp/chamlinux/ chamlinux/tmp/chamlinux/2/ chamlinux/tmp/cham/ chamlinux/tmp/cham/chamlinux/ chamlinux/tmp/cham/chamlinux/2/ chamlinux/tmp/cham1/ chamlinux/tmp/cham1/2/ chamlinux/tmp/cham1/chamlinux/ chamlinux/tmp/cham1/chamlinux/2/ chamlinux/tmp/ping/ chamlinux/tmp/ping/88.txt chamlinux/tmp/d6z/ chamlinux/tmp/d6z/chamlinux/ chamlinux/tmp/d6z/chamlinux/2/ chamlinux/tmp/d6z/2.txt.gz chamlinux/tmp/d6z/3.txt chamlinux/tmp/d6z/1.txt chamlinux/tmp/d6z/4.txt chamlinux/tmp/1.txt chamlinux/tmp/.ch chamlinux/tmp/ch.log chamlinux/tmp/88.txt chamlinux/tmp/.99.txt
說明: 解包時,若是該文件已經存在則會直接覆蓋,無任何提示。
語法: tar [options] [filename]
options:
-z:同時用gzip壓縮
-j:同時用bzip2壓縮
-J:同時用xz壓縮
打包並用gzip壓縮
[root@cham3 d6z]# tar -czvf chamlinux.tar.gz chamlinux 3.txt 4.txt chamlinux/ chamlinux/2/ chamlinux/2/4.txt chamlinux/tmp/ chamlinux/tmp/.ICE-unix/ chamlinux/tmp/.X11-unix/ chamlinux/tmp/.Test-unix/ chamlinux/tmp/.XIM-unix/ chamlinux/tmp/.font-unix/ chamlinux/tmp/chamlinux/ chamlinux/tmp/chamlinux/2/ chamlinux/tmp/cham/ chamlinux/tmp/cham/chamlinux/ chamlinux/tmp/cham/chamlinux/2/ chamlinux/tmp/cham1/ chamlinux/tmp/cham1/2/ chamlinux/tmp/cham1/chamlinux/ chamlinux/tmp/cham1/chamlinux/2/ chamlinux/tmp/ping/ chamlinux/tmp/ping/88.txt chamlinux/tmp/d6z/ chamlinux/tmp/d6z/chamlinux/ chamlinux/tmp/d6z/chamlinux/2/ chamlinux/tmp/d6z/2.txt.gz chamlinux/tmp/d6z/3.txt chamlinux/tmp/d6z/1.txt chamlinux/tmp/d6z/4.txt chamlinux/tmp/1.txt chamlinux/tmp/.ch chamlinux/tmp/ch.log chamlinux/tmp/88.txt chamlinux/tmp/.99.txt 3.txt 4.txt [root@cham3 d6z]# du -sh chamlinux.tar.gz 3.2M chamlinux.tar.gz [root@cham3 d6z]# du -sh chamlinux 3.txt 4.txt 8.0M chamlinux 2.0M 3.txt 2.0M 4.txt
打包並用bzip2壓縮
[root@cham3 d6z]# tar -cjvf chamlinux.tar.bz2 chamlinux chamlinux/ chamlinux/2/ chamlinux/2/4.txt chamlinux/tmp/ chamlinux/tmp/.ICE-unix/ chamlinux/tmp/.X11-unix/ chamlinux/tmp/.Test-unix/ chamlinux/tmp/.XIM-unix/ chamlinux/tmp/.font-unix/ chamlinux/tmp/chamlinux/ chamlinux/tmp/chamlinux/2/ chamlinux/tmp/cham/ chamlinux/tmp/cham/chamlinux/ chamlinux/tmp/cham/chamlinux/2/ chamlinux/tmp/cham1/ chamlinux/tmp/cham1/2/ chamlinux/tmp/cham1/chamlinux/ chamlinux/tmp/cham1/chamlinux/2/ chamlinux/tmp/ping/ chamlinux/tmp/ping/88.txt chamlinux/tmp/d6z/ chamlinux/tmp/d6z/chamlinux/ chamlinux/tmp/d6z/chamlinux/2/ chamlinux/tmp/d6z/2.txt.gz chamlinux/tmp/d6z/3.txt chamlinux/tmp/d6z/1.txt chamlinux/tmp/d6z/4.txt chamlinux/tmp/1.txt chamlinux/tmp/.ch chamlinux/tmp/ch.log chamlinux/tmp/88.txt chamlinux/tmp/.99.txt [root@cham3 d6z]# du -sh chamlinux.tar.bz2 580K chamlinux.tar.bz2
打包並用xz壓縮
[root@cham3 d6z]# tar -cJvf chamlinux.tar.xz chamlinux chamlinux/ chamlinux/2/ chamlinux/2/4.txt chamlinux/tmp/ chamlinux/tmp/.ICE-unix/ chamlinux/tmp/.X11-unix/ chamlinux/tmp/.Test-unix/ chamlinux/tmp/.XIM-unix/ chamlinux/tmp/.font-unix/ chamlinux/tmp/chamlinux/ chamlinux/tmp/chamlinux/2/ chamlinux/tmp/cham/ chamlinux/tmp/cham/chamlinux/ chamlinux/tmp/cham/chamlinux/2/ chamlinux/tmp/cham1/ chamlinux/tmp/cham1/2/ chamlinux/tmp/cham1/chamlinux/ chamlinux/tmp/cham1/chamlinux/2/ chamlinux/tmp/ping/ chamlinux/tmp/ping/88.txt chamlinux/tmp/d6z/ chamlinux/tmp/d6z/chamlinux/ chamlinux/tmp/d6z/chamlinux/2/ chamlinux/tmp/d6z/2.txt.gz chamlinux/tmp/d6z/3.txt chamlinux/tmp/d6z/1.txt chamlinux/tmp/d6z/4.txt chamlinux/tmp/1.txt chamlinux/tmp/.ch chamlinux/tmp/ch.log chamlinux/tmp/88.txt chamlinux/tmp/.99.txt [root@cham3 d6z]# du -sh chamlinux.tar.xz 44K chamlinux.tar.xz
查看包內容
[root@cham3 d6z]# tar -tf chamlinux.tar.bz2 chamlinux/ chamlinux/2/ chamlinux/2/4.txt chamlinux/tmp/ chamlinux/tmp/.ICE-unix/ chamlinux/tmp/.X11-unix/ chamlinux/tmp/.Test-unix/ chamlinux/tmp/.XIM-unix/ chamlinux/tmp/.font-unix/ chamlinux/tmp/chamlinux/ chamlinux/tmp/chamlinux/2/ chamlinux/tmp/cham/ chamlinux/tmp/cham/chamlinux/ chamlinux/tmp/cham/chamlinux/2/ chamlinux/tmp/cham1/ chamlinux/tmp/cham1/2/ chamlinux/tmp/cham1/chamlinux/ chamlinux/tmp/cham1/chamlinux/2/ chamlinux/tmp/ping/ chamlinux/tmp/ping/88.txt chamlinux/tmp/d6z/ chamlinux/tmp/d6z/chamlinux/ chamlinux/tmp/d6z/chamlinux/2/ chamlinux/tmp/d6z/2.txt.gz chamlinux/tmp/d6z/3.txt chamlinux/tmp/d6z/1.txt chamlinux/tmp/d6z/4.txt chamlinux/tmp/1.txt chamlinux/tmp/.ch chamlinux/tmp/ch.log chamlinux/tmp/88.txt chamlinux/tmp/.99.txt [root@cham3 d6z]# tar -tf chamlinux.tar.xz chamlinux/ chamlinux/2/ chamlinux/2/4.txt chamlinux/tmp/ chamlinux/tmp/.ICE-unix/ chamlinux/tmp/.X11-unix/ chamlinux/tmp/.Test-unix/ chamlinux/tmp/.XIM-unix/ chamlinux/tmp/.font-unix/ chamlinux/tmp/chamlinux/ chamlinux/tmp/chamlinux/2/ chamlinux/tmp/cham/ chamlinux/tmp/cham/chamlinux/ chamlinux/tmp/cham/chamlinux/2/ chamlinux/tmp/cham1/ chamlinux/tmp/cham1/2/ chamlinux/tmp/cham1/chamlinux/ chamlinux/tmp/cham1/chamlinux/2/ chamlinux/tmp/ping/ chamlinux/tmp/ping/88.txt chamlinux/tmp/d6z/ chamlinux/tmp/d6z/chamlinux/ chamlinux/tmp/d6z/chamlinux/2/ chamlinux/tmp/d6z/2.txt.gz chamlinux/tmp/d6z/3.txt chamlinux/tmp/d6z/1.txt chamlinux/tmp/d6z/4.txt chamlinux/tmp/1.txt chamlinux/tmp/.ch chamlinux/tmp/ch.log chamlinux/tmp/88.txt chamlinux/tmp/.99.txt [root@cham3 d6z]# tar -tf chamlinux.tar.gz chamlinux/ chamlinux/2/ chamlinux/2/4.txt chamlinux/tmp/ chamlinux/tmp/.ICE-unix/ chamlinux/tmp/.X11-unix/ chamlinux/tmp/.Test-unix/ chamlinux/tmp/.XIM-unix/ chamlinux/tmp/.font-unix/ chamlinux/tmp/chamlinux/ chamlinux/tmp/chamlinux/2/ chamlinux/tmp/cham/ chamlinux/tmp/cham/chamlinux/ chamlinux/tmp/cham/chamlinux/2/ chamlinux/tmp/cham1/ chamlinux/tmp/cham1/2/ chamlinux/tmp/cham1/chamlinux/ chamlinux/tmp/cham1/chamlinux/2/ chamlinux/tmp/ping/ chamlinux/tmp/ping/88.txt chamlinux/tmp/d6z/ chamlinux/tmp/d6z/chamlinux/ chamlinux/tmp/d6z/chamlinux/2/ chamlinux/tmp/d6z/2.txt.gz chamlinux/tmp/d6z/3.txt chamlinux/tmp/d6z/1.txt chamlinux/tmp/d6z/4.txt chamlinux/tmp/1.txt chamlinux/tmp/.ch chamlinux/tmp/ch.log chamlinux/tmp/88.txt chamlinux/tmp/.99.txt 3.txt 4.txt
示例:解包並解壓xz格式的包
[root@cham3 d6z]# tar -Jxvf chamlinux.tar.xz chamlinux/ chamlinux/2/ chamlinux/2/4.txt chamlinux/tmp/ chamlinux/tmp/.ICE-unix/ chamlinux/tmp/.X11-unix/ chamlinux/tmp/.Test-unix/ chamlinux/tmp/.XIM-unix/ chamlinux/tmp/.font-unix/ chamlinux/tmp/chamlinux/ chamlinux/tmp/chamlinux/2/ chamlinux/tmp/cham/ chamlinux/tmp/cham/chamlinux/ chamlinux/tmp/cham/chamlinux/2/ chamlinux/tmp/cham1/ chamlinux/tmp/cham1/2/ chamlinux/tmp/cham1/chamlinux/ chamlinux/tmp/cham1/chamlinux/2/ chamlinux/tmp/ping/ chamlinux/tmp/ping/88.txt chamlinux/tmp/d6z/ chamlinux/tmp/d6z/chamlinux/ chamlinux/tmp/d6z/chamlinux/2/ chamlinux/tmp/d6z/2.txt.gz chamlinux/tmp/d6z/3.txt chamlinux/tmp/d6z/1.txt chamlinux/tmp/d6z/4.txt chamlinux/tmp/1.txt chamlinux/tmp/.ch chamlinux/tmp/ch.log chamlinux/tmp/88.txt chamlinux/tmp/.99.txt
說明: 其他兩種壓縮格式同理。