日期:2014-05-16  浏览次数:20792 次

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


      前几天笔记本新装的系统,想重新编个内核,结果……傻眼了,居然使用 tar -xvjf  linux-*** 解压不了,定睛一看,发现现在kernel官网下载的内核压缩包居然不是bz2了!!!而是tar.xz……What the fuck! 额……不说脏话,啥时候改这个格式了!而且……这特么是什么格式?我怎么没见过?只能尝试着搜索下xz是什么:

【注】:我使用的是 Ubuntu12.04 系统,因而使用的包管理命令是aptitude ,使用别的发行版请使用相应的包管理命令进行!

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:~$ 

好吧,中文系统就是好!仔细看这一行:

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文件: