歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> Linux下解壓tar.xz格式壓縮文件

Linux下解壓tar.xz格式壓縮文件

日期:2017/3/1 16:27:52   编辑:關於Linux
Linux下解壓tar.xz格式壓縮文件 前幾天筆記本新裝的系統,想重新編個內核,結果……傻眼了,居然使用 tar -xvjf linux-*** 解壓不了,定睛一看,發現現在kernel官網下載的內核壓縮包居然不是bz2了!!!而是tar.xz……What the fuck! 額……不說髒話,啥時候改這個格式了!而且……這特麼是什麼格式?我怎麼沒見過?只能嘗試著搜索下xz是什麼: 【注】:我使用的是 Ubuntu12.04 系統,因而使用的包管理命令是aptitude ,使用別的發行版請使用相應的包管理命令進行! [cpp] long@long-Ubuntu:~$ aptitude search xz p libxz-java - Java library with a complete implementation of XZ data compression p libxz-java-doc - Documentation for libxz-java p python-txzookeeper - Twisted-based Asynchronous Libraries for Apache Zookeeper. v python2.7-txzookeeper - i xz-utils - XZ 格式壓縮程序 p xzdec - XZ-format compression utilities - tiny decompressors p xzgv - Picture viewer for X with a thumbnail-based selector p xzip - Interpreter of Infocom-format story-files p xzoom - magnify part of X display, with real-time updates long@long-Ubuntu:~$ 好吧,中文系統就是好!仔細看這一行: [cpp] i xz-utils - XZ 格式壓縮程序 直接標識的很清楚,XZ壓縮程序,而且好像我的Ubuntu已經自帶的安裝好了(沒有的話就用 apt-get 安裝)!遇事找男人(man一下)呗:man xz 看看怎麼操作 可以看到,xz的用法為: xz [option]... [file]... 而對應的操作有: -z, --compress Compress. This is the default operation mode when no operation mode option is specified and no other operation mode is implied from the command name (for example, unxz implies --decompress). 壓縮,而且這是默認的操作,也就是說沒有操作數的話 xz 加上文件就是壓縮!(unxz 可以用來解壓) -d, --decompress, --uncompress Decompress. 解壓縮。和 -z 效果相反 -t, --test Test the integrity of compressed files. This option is equivalent to --decompress --stdout except that the decompressed data is discarded instead of being written to standard output. No files are created or removed. 測試壓縮文件的完整性,這個操作不會生成解壓縮文件。 -l, --list Print information about compressed files. No uncompressed output is produced, and no files are created or removed. In list mode, the program cannot read the compressed data from standard input or from other unseekable sources. 這個操作會打印文件的信息,不會生成解壓縮文件! 所以,我們從內核官網下載的壓縮文件可以使用下面兩個操作進行解壓: 1.首先使用xz解壓 tar.xz文件: xz -d linux-3.8.4.tar.xz 這個操作會將linux-3.8.4.tar.xz文件解壓成 linux-3.8.4.tar,然後我們再對 linux-3.8.4.tar 進行解壓。 【注】:使用 xz 進行壓縮和解壓過程中都會直接在原文件上進行,比如說對 tar.xz 解壓後直接就剩下 tar 了,而沒有了原 tar.xz 文件。可以加 -k 參數(keep)進行保留原文件 2.對linux-3.8.4.tar解壓:tar -xvf linux-3.8.4.tar 操作完成 最後再補充下 xz utils 的知識: xz utils 是 lzma utils 的下一代lzma utils 改名 xz utils。 壓縮時 xz utils 耗時比 bzip2 長一倍, 壓縮時 xz utils 耗時是 lzma utils 一半, 壓縮時 xz utils 生成文件體積是 bzip2 的一半, 壓縮時 xz utils 生成文件體積比 lzma utils 略大, 解壓時 xz utils 耗時是 bzip2 的三分之一, 解壓時 xz utils 速度比 lzma utils 略快, 解壓時 xz utils 耗時僅比 gzip 多一倍。 壓縮時 xz utils 使用 *.xz 格式 生成文件 比 *.lzma 格式 略大, 測試樣本較小,多次測試結果有出入,無法判斷 xz utils 使用 *.xz 與 *.lzma 格式 壓縮與解壓時間 誰占優勢。 到目前為止,lzma utils 的壓縮率仍是最大的,xz utils 解壓時間占優勢。 一個 xz 文件格式的實現XZ 實用程序已可在網上自由獲得。GNU tar自版本1.22起使用這一軟件透明支持xz文件格式(就如同其處理gzip格式或者bzip2格式一樣)。 隨著大量軟件進入了公有領域(例如 liblzma等) 程序的4.999.9beta版本實現在GNU LGPL 和 GNU GPL條款下發布。 7-Zip在9.04 beta版支持了xz文件格式,也就是說在windows下遇到 xz 壓縮文件可以使用 7-Zip 解壓。
Copyright © Linux教程網 All Rights Reserved