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

本文详细介绍了xz命令的基本用法,包括压缩、解压、测试文件完整性和列出文件信息等操作。重点演示了如何使用xz解压tar.xz文件,并在解压过程中保留原始文件的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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)进行保留原文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值