XZ的介绍

 

今天升级Python的时候,下载的Python-2.7.8.tar.xz安装包为xz格式,好吧,我又孤陋寡闻了,居然第一次遇见xz格式的压缩文件。搜索了一下资料,下面是xz的一些介绍:

xz是一个使用 LZMA压缩算法的无损数据压缩文件格式。和gzip与bzip2一样,同样支持多文件压缩,但是约定不能将多于一个的目标文件压缩进同一个档案文件。相反,xz通常作为一种归档文件自身的压缩格式,例如使用tar或cpioUnix程序创建的归档。xz 在GNU coreutils(版本 7.1 或更新)中被使用。xz 作为压缩软件包被收录在 Fedora (自Fedora 12起), Arch Linux, FreeBSD、 Slackware Linux、CRUX 和 Funtoo中。

XZ Utils压缩代码的核心是基于LZMA SDK,但它已经被修改了很多以适应XZ Utils。主压缩算法目前是LZMA2,它在.xz容器格式中使用。 使用典型文件,XZ Utils比gzip创建的输出比gzip小30%,比bzip2小15%。到目前为止,lzma utils 的压缩率仍是最大的,XZ Utils 解压时间占优势。

XZ Utils的官方网站为:http://tukaani.org/xz/ ,官网关于XZ的介绍资料如下:

 

XZ Utils

 

XZ Utils is free general-purpose data compression software with a high compression ratio. XZ Utils were written for POSIX-like systems, but also work on some not-so-POSIX systems. XZ Utils are the successor to LZMA Utils.

The core of the XZ Utils compression code is based on LZMA SDK, but it has been modified quite a lot to be suitable for XZ Utils. The primary compression algorithm is currently LZMA2, which is used inside the .xz container format. With typical files, XZ Utils create 30 % smaller output than gzip and 15 % smaller output than bzip2.

XZ Utils consist of several components:

·         liblzma is a compression library with an API similar to that of zlib.

·         xz is a command line tool with syntax similar to that of gzip.

·         xzdec is a decompression-only tool smaller than the full-featured xz tool.

·         A set of shell scripts (xzgrep, xzdiff, etc.) have been adapted from gzip to ease viewing, grepping, and comparing compressed files.

·         Emulation of command line tools of LZMA Utils eases transition from LZMA Utils to XZ Utils.

While liblzma has a zlib-like API, liblzma doesn't include any file I/O functions. A separate I/O library is planned, which would abstract handling of .gz, .bz2, and .xz files with an easy to use API.

XZ的安装

从官方网址下载https://tukaani.org/xz/xz-5.2.3.tar.gz后,安装非常简单。如果你可以yum安装,那么就更简单。有些版本甚至默认就自带xz压缩命令。

tar -xzvf xz-5.2.3.tar.gz

cd xz-5.2.3

./configure

make

make install

XZ的使用

 

-z

force compression

压缩文件

-d

force decompression

解压文件

-t

test compressed file integrity

测试压缩文件完整性

-l

list information about .xz files

列出压缩文件.xz的一些信息

-k

keep (don't delete) input files

保留被解压缩的文件

-f

force overwrite of output file and (de)compress links

强制覆盖输出文件和(de)压缩链接

-c

write to standard output and don't delete input files

压缩输入标准输出并保留被压缩的文件。

-0 … -9

compression preset; default is 6; take compressor *and*                    decompressor memory usage into account before using 7-9!

压缩率预设参数 -0 到 -9调节压缩率。如果不设置,默认压缩等级是6

-e

try to improve compression ratio by using more CPU time;                      does not affect decompressor memory requirements

尝试通过使用更多的CPU时间来提高压缩比; 不影响解压内存的要求

-T

use at most NUM threads; the default is 1; set to 0 to use as many threads as there are processor cores

压缩的线程数量。默认为1,设置为0表示跟处理器核数匹配

-q

suppress warnings; specify twice to suppress errors too

抑制警告 指定两次以抑制错误

-v

be verbose; specify twice for even more verbose

显示压缩、解压详细信息

-H

display the long help (lists also the advanced options)

显示更多的帮助信息,包含告警选项。

-V

display the version number and exit

显示版本信息并退出

解压文件方法1

[root@DB-Server tmp]# xz -d Python-2.7.8.tar.xz 

 

[root@DB-Server tmp]# tar -xf Python-2.7.8.tar

解压文件方法2,一次性搞定,但是需要tar支持,有些低版本tar并不支持

[root@DB-Server tmp]#tar -Jxf Python-2.7.8.tar.xz 

压缩文件

[root@DB-Server tmp]# xz -z Python-2.7.8.tar 

 

 

[root@DB-Server tmp]#tar -Jcf Python-2.7.8.tar.xz Python-2.7.8/

查看压缩文件信息

[root@DB-Server tmp]# xz -l Python-2.7.8.tar.xz

 

Strms  Blocks   Compressed Uncompressed  Ratio  Check   Filename

 

    1       1     10.0 MiB     63.2 MiB  0.159  CRC64   Python-2.7.8.tar.xz

 

[root@DB-Server tmp]# 

压缩比例简单测试:

 

[root@DB-Server tmp]# ls -lrt Python-2.7.8.tar 

-rw-r--r-- 1 root root 66263040 Sep 21 22:49 Python-2.7.8.tar

[root@DB-Server tmp]# xz -z Python-2.7.8.tar 

[root@DB-Server tmp]# ls -lrt Python-2.7.8.tar.xz 

-rw-r--r-- 1 root root 10525244 Sep 21 22:49 Python-2.7.8.tar.xz

[root@DB-Server tmp]# xz -d Python-2.7.8.tar.xz 

[root@DB-Server tmp]# gzip  Python-2.7.8.tar 

[root@DB-Server tmp]# ls -lrt Python-2.7.8.tar.gz 

-rw-r--r-- 1 root root 14991942 Sep 21 22:49 Python-2.7.8.tar.gz

[root@DB-Server tmp]# gizp -d Python-2.7.8.tar.gz 

-bash: gizp: command not found

[root@DB-Server tmp]# gzip -d Python-2.7.8.tar.gz 

[root@DB-Server tmp]# zip  Python-2.7.8.tar.gzip  Python-2.7.8.tar 

  adding: Python-2.7.8.tar (deflated 77%)

[root@DB-Server tmp]#  ls -lrt Python-2.7.8.tar.gzip 

-rw-r--r-- 1 root root 14992071 Sep 22 12:11 Python-2.7.8.tar.gzip

如上简单测试所示, gzip、zip、xz压缩的大小对比

Python-2.7.8.tar.xz              10525244

Python-2.7.8.tar.gz              14991942

Python-2.7.8.tar.gzip            14992071

 

 

参考资料:

https://teddysun.com/294.html

Linux XZ压缩格式学习的更多相关文章

  1. Linux 常见压缩格式详解

    linux 文件压缩格式详解 压缩文件原理 在计算机科学和信息论中,数据压缩或者源编码是按照特定的编码机制用比未经编码少的数据比特(或者其它信息相关的单位)表示信息的过程.例如,如果我们将" ...

  2. linux xz压缩解压

    1. 解压 xz 格式文件 方法一: 需要用到两步命令,首先利用 xz-utils 的 xz 命令将 linux-3.12.tar.xz 解压为 linux-3.12.tar,其次用 tar 命令将 ...

  3. 常见压缩格式分析,及 Linux 下的压缩相关指令

    可先浏览加粗部分 一.常见压缩档 *.zip | zip 程式壓縮打包的檔案: (很常见,但是因为不包含文件名编码信息,跨平台可能会乱码) *.rar | winrar 程序压缩打包的档案:(在win ...

  4. Linux XZ格式的解压

    xz这个压缩可能很多都很陌生,不过您可知道xz是绝大数linux默认就带的一个压缩工具. 之前xz使用一直很少,所以几乎没有什么提起. 我是在下载phpmyadmin的时候看到这种压缩格式的,phpm ...

  5. linux下关于gz和bz2压缩格式的常用操作技巧

    .gz和.bz2都是linux下压缩文件的格式,有点类似windows下的.zip和.rar文件..bz2和.gz的区别在于,前者比后者压缩率更高,后者比前者花费更少的时间. 也就是说同一个文件,压缩 ...

  6. .xz文件解压及linux常见压缩

    最近下载mysql8.0的压缩包,发现压缩包的格式为xz tar czvf 或 tar xzvf 的压缩格式很好解压,使用tar命令即可,z是针对 gzip,j是针对 bzip2. 但xz的压缩文件就 ...

  7. Linux下zip格式文件的解压缩和压缩

    Linux下zip格式文件的解压缩和压缩 Linux下的软件包很多都是压缩包,软件的安装就是解压缩对应的压缩包.所以,就需要熟练使用常用的压缩命令和解压缩命令.最常用的压缩格式有.tar.gz/tgz ...

  8. 如何在linux下解压缩rar格式的文件压缩包

    ##########################################################如何在linux下解压缩rar格式的文件压缩包#date:2014年2月15日22: ...

  9. zip,rar及linux下常用的压缩格式

    日常操作中我们经常使用到文件压缩操作,其使用一些特定的算法来减小文件的大小,可以提高传输数据时的速率和减少数据在一些存储机制上占有的空间大小,实现空间利用最大化. 比如:如果你想通过邮箱发送一个文件夹 ...

随机推荐

  1. 【转】python入门指引

    http://matrix.42qu.com/10757179 前言 其实我也不知道python怎么入门,由我来写这个真的不是很合适.我学python是直接找了dive into python来看.然 ...

  2. Hibernate的五个主要接口

    Hibernate作为持久成中间件,它的具体实现对与上层调用是透明的,即上层通过接口来调用Hibernate的具体实现,所以对于入门级别的讨论来说,自然应该先从接口开始了.

  3. zookeeper 实现分布式锁

    主要是依赖临时节点的特性.数据存储到内存中效率高:例如有web1 web2 两台应用服务器 db1 db2两台db服务器  db互为主备,web1 web2 分别去修改db1 .有限db2库里张三的年 ...

  4. Apache自带的rotatelogs实现日志轮转

    用Apache自带的rotatelogs程序处理apache生成的日志自动截断重新生成,rotatelogs是一个配合Apache管道日志功能使用的简单程序.设置方法如下: 编辑Apache的主配置文 ...

  5. GreenDao 兼容升级,保留旧数据的---全方面解决方案

    作者:林冠宏 / 指尖下的幽灵 掘金:https://juejin.im/user/587f0dfe128fe100570ce2d8 博客:http://www.cnblogs.com/linguan ...

  6. Java程序只运行一个实例[转]

    如果希望你的Java程序只能存在一个实例,可以参考下面的用法. 原文链接:http://blog.csdn.net/yaerfeng/article/details/7264729 Java没有提供这 ...

  7. Codevs 3990 [中国剩余定理]

    模板题 注意如何得到[a,b]区间范围内的解 #include <iostream> #include <cstdio> #include <cstring> #i ...

  8. 使用websocket实现在线聊天功能

    很早以前为了快速达到效果,使用轮询实现了在线聊天功能,后来无意接触了socket,关于socket我的理解是进程间通信,首先要有服务器跟客户端,服务的启动监听某ip端口定位该进程,客户端开启socke ...

  9. 如何知道你的linux是什么时候安装的

    在安装系统时,每个分区下都会有一个 lost+found,而且这个目录的创建时间是和该分区创建的时间一样的.所以如果想知道你的系统是什么时候安装的,只需要看这个目录的创建时间即可. 通常情况下,我们分 ...

  10. .Net Core和jexus配置HTTPS服务

    花了几天时间,看了好多篇博客,终于搞定了网站的HTTPS服务,借此写篇博客,来让有需要的朋友少走弯路. 一.环境介绍 1.Linux下在Docker容器中部署好了一个网站,该网站需要通过外部提供程序访 ...