Linux下解压tar.xz格式压缩文件


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 解压。

相关内容

    暂无相关文章