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

转载于:https://www.cnblogs.com/kerrycode/p/7574745.html

Linux XZ压缩格式学习相关推荐

  1. linux 常用压缩格式,Linux常见压缩格式之压缩与解压

    Linux常见压缩格式之压缩与解压 zip格式 压缩:zip -r [目标文件名].zip [原文件/目录名] 解压:unzip [原文件名].zip 注:-r参数代表递归 # Extract arc ...

  2. linux 压缩文件性能,Linux常见压缩格式Tar、Zip和Gz格式之不同

    Linux 中大家在下载文件时常见的压缩文件有 .tar..zip 或 .gz 等扩展名,大多数用户都已经见怪不怪了.那 Linux 中为什么要搞出这么多种压缩格式,Tar.Zip 和 Gz 之间到底 ...

  3. linux 常用压缩格式,Linux下常用压缩格式的压缩与解压方法

    Linux下常用压缩格式的压缩与解压方法 --------------------------------------------- .tar 打包:tar cvf *.tar *.*(原文件或目录) ...

  4. linux xz压缩解压

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

  5. linux命令里的xz是干嘛的,linux xz命令详解

    xz命令是绝大数linux系统默认就带的一个压缩工具.那么它的具体语法是怎样的呢?下面由学习啦小编为大家整理了linux xz命令的相关知识,希望对大家有帮助. linux xz命令详解 1.linu ...

  6. CentOs下各种压缩格式的创建及解压缩

    压/解压缩文件:gzip && bzip2 && xz gzip(默认删除原来的文件) 压缩命令: [ gzip 文件名 ](有后缀记得加上哦~ 否则会出现  No s ...

  7. Linux的压缩及归档

    Linux的压缩及归档详解 Linux的压缩格式主要有gz.bz2.xz以及Z这四种,压缩的过程是我们的系统利用压缩算法来进行实现的,压缩算法不同,压缩比就会不同,压缩文件的过程是先利用压缩算法去扫描 ...

  8. linux xz 解压initrd.img,2016-8-28 linux基础学习——压缩解压缩及归档 while脚本

    文件管理命令----压缩解压缩及归档基本工具 压缩.解压缩命令 压缩格式:gz, bz2, xz, zip, Z 压缩算法:算法不同,压缩比也会不同: 早期 压缩: compress(压缩比很小): ...

  9. Linux的XZ压缩

    现在很多找到的软件都是tar.xz的格式的,xz 是一个使用 LZMA压缩算法的无损数据压缩文件格式. 和gzip与bzip2一样,同样支持多文件压缩,但是约定不能将多于一个的目标文件压缩进同一个档案 ...

  10. linux xz 解压initrd.img,initrd.img的压缩(制作)及解压的过程

    一.启动镜像initrd.img 文件 类RedHat 系统从vmlinuz 核心引导后,会读取initrd.img 启动镜像.该文件中包含驱动模块等信息,是非常重要的文件.不同版本使用的格式不同. ...

最新文章

  1. 护壁桩嵌入深度_泥浆护壁成孔灌注桩施工时泥浆的作用有哪些?
  2. java sdcard path_更改 android 文件存放目录 getWritablePath() 为sdCard
  3. framebuffer结构体分析
  4. 词法分析器构造工具Flex基础学习
  5. 机房日常技术总结——Windows篇
  6. oninput,onpropertychange,onchange的用法和区别
  7. nginx 反向代理+ip智能解析
  8. VMWare 虚拟机中安装 CentOS 7
  9. python字典类型可迭代_核心数据类型--字典
  10. Google 加入反 IE6 联盟:IE6 真的能被消灭吗?
  11. java 登陆拦截_登录拦截 - java代码库 - 云代码
  12. 老程序员应该记住的 5 件事
  13. 最小的浏览器-橘子浏览器才1M大小
  14. Google Chrome(谷歌浏览器)安装方法与使用技巧
  15. polyval matlab 怎么用,matlab 中polyval的用法 最好能举个例子
  16. div 空隙的解决办法
  17. ARM开发板 瑞芯微RK3288开发板
  18. Norgen AAV提取剂盒说明书(含特色)
  19. SIR SIRE 传染病预测模型与代码应用之概念篇
  20. c 语言怎么实现可视化编程,自定义编程语言的实现

热门文章

  1. 如何在 iPhone 和 iPad 上关闭 Spotlight 建议?
  2. Adobe系列错误代码解决方案汇总
  3. Spring中使用Quartz之MethodInvokingJobDetailFactoryBean配置任务
  4. React Advanced 备忘
  5. inux_异常_07_ftp查看不到文件列表
  6. 网站发布后验证码不显示
  7. 以太坊系列之十四: solidity特殊函数
  8. 没有Angular 3,下一个Angular主版本将是Angular 4
  9. wpf之DataTrigger 数据触发器
  10. Zend_Db_Statement 一行无用代码