Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the xz command in Linux

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use the xz command in Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.

Linux common command xz command XZ Utils is a tool with high compression ratio developed for the POSIX platform. It uses the LZMA2 compression algorithm to generate compressed files that are smaller than those generated by gzip and bzip2, which are traditionally used on the POSIX platform, and the decompression speed is also very fast.

Developing tools with high compression ratio on xzPOSIX platform

It is added that XZ Utils was originally developed based on LZMA-SDK, but LZMA-SDK contains some features of the WINDOWS platform, so XZ Utils has made significant changes to adapt to the POSIX platform. XZ Utils also appeared to replace the old LZMA Utils in POSIX system.

Syntax xz (option) (parameter) xz [OPTION]... [FILE]... Option-z,-- compress # force compression-d,-- decompress,-- uncompress # force decompression-t,-- test # Test the integrity of compressed files-l,-- list # list information about .xz files-k,-- keep # keep (do not delete) input files-f -- force # forcibly overwrites the output file and (unzips) the link-c,-- stdout,-- to-stdout # writes to standard output Do not delete the input file-0.-9 # compression preset The default is 6; take the compressor * and * # into account before decompressing memory usage before using 7-9! -e,-- extreme # attempts to improve the compression ratio by using more CPU time; # requires no impact on the unzipped memory-T,-- threads=NUM # uses up to NUM threads; the default value is 1; set to 0 # is set to 0, using as many threads as the processor kernel-Q,-- quiet # suppresses warnings Specify twice to suppress the error-v,-- verbose # verbosity; specify twice for more detail-h,-- help # to display this concise help and exit-H,-- long-help # to show more help (advanced options are also listed)-V,-- version # to display the version number and exit the parameter source file: specify the source file for the connection.

Destination file: specifies the destination connection file for the source file.

The instance compresses a file test.txt. After the compression is successful, the test.txt.xz is generated, and the original file is deleted.

$xz test.txt $ls test.txt* test.txt.xz extract the test.txt.xz file and use the parameter-k to keep the original file from being deleted

$xz-d-k test.txt.xz $ls test.txt* test.txt.xz test.txt uses the parameter-l to display the basic information of the .xz file. The basic information includes compression ratio, data integrity verification method and so on. You can also display more detailed information in conjunction with the parameter-v or-vv.

Xz-l index.txt.xz # Strms Blocks Compressed Uncompressed Ratio Check Filename # 1 1 768 B 1240 B 0.619 CRC64 index.txt. Use the parameter-0,-1,-2,... -6,... -9 or parameter-fast,-best sets the compression ratio. The default for the xz command is-6, for most systems, even some older systems,-4... The preset values of-6 compression ratio are all good performance.

$xz-K7 xz_pipe_decomp_mini.c $xz-k-- fast xz_pipe_decomp_mini.c uses the parameter-H to display all options of the xz command. The parameter-H is displayed in more detail than using the parameter-help.

$xz-H | more compresses multiple files in parallel with the xargs command. The following command line compresses all files with a .log extension in the / var/log directory. Use the xargs command to run multiple xz simultaneously to compress.

# root permission is required to run this command. Find / var/log-type f-iname "* .log"-print0 | xargs-P4-n16 xz-T1 Thank you for reading this article carefully. I hope the article "how to use xz commands in Linux" shared by the editor will be helpful to you. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report