您好,登錄后才能下訂單哦!
今天小編給大家分享一下linux中xz命令怎么使用的相關(guān)知識點(diǎn),內(nèi)容詳細(xì),邏輯清晰,相信大部分人都還太了解這方面的知識,所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。
linux中xz是用于對系統(tǒng)文件進(jìn)行壓縮和解壓縮的命令,壓縮完成后,系統(tǒng)會自動在原文件后加上“.xz”的擴(kuò)展名并刪除原文件;xz命令只能對文件進(jìn)行壓縮,不能對目錄進(jìn)行壓縮。
xz命令:POSIX 平臺開發(fā)具有高壓縮率的工具。它使用 LZMA2 壓縮算法,生成的壓縮文件比 POSIX 平臺傳統(tǒng)使用的 gzip、bzip2 生成的壓縮文件更小,而且解壓縮速度也很快,壓縮或解壓縮xz文件。
功能說明:
xz命令會對系統(tǒng)文件進(jìn)行壓縮和解壓縮,壓縮完成后,系統(tǒng)會自動在原文件后加上.xz的擴(kuò)展名并刪除原文件。xz命令只能對文件進(jìn)行壓縮,不能對目錄進(jìn)行壓縮。
語法結(jié)構(gòu):
xz(選項(xiàng))(參數(shù))
xz [OPTION]... [FILE]...
xz --help
Usage: xz [OPTION]... [FILE]...
Compress or decompress FILEs in the .xz format.
-z, --compress force compression
-d, --decompress, --uncompress
force decompression
-t, --test test compressed file integrity
-l, --list list information about .xz files
-k, --keep keep (don't delete) input files
-f, --force force overwrite of output file and (de)compress links
-c, --stdout, --to-stdout
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!
-e, --extreme try to improve compression ratio by using more CPU time;
does not affect decompressor memory requirements
-T, --threads=NUM use at most NUM threads; the default is 1; set to 0
to use as many threads as there are processor cores
-q, --quiet suppress warnings; specify twice to suppress errors too
-v, --verbose be verbose; specify twice for even more verbose
-h, --help display this short help and exit
-H, --long-help display the long help (lists also the advanced options)
-V, --version display the version number and exit
With no FILE, or when FILE is -, read standard input.
Report bugs to <lasse.collin@tukaani.org> (in English or Finnish).
XZ Utils home page: <http://tukaani.org/xz/>
-z, --compress # 強(qiáng)制壓縮
-d, --decompress, --uncompress
# force decompression
-t, --test # 測試壓縮文件的完整性
-l, --list # 列出有關(guān).xz文件的信息
-k, --keep # 保留(不要刪除)輸入文件
-f, --force # 強(qiáng)制覆蓋輸出文件和(解)壓縮鏈接
-c, --stdout, --to-stdout
# 寫入標(biāo)準(zhǔn)輸出,不要刪除輸入文件
-0 ... -9 # 壓縮預(yù)設(shè); 默認(rèn)為6; 取壓縮機(jī)*和*
# 使用7-9之前解壓縮內(nèi)存使用量考慮在內(nèi)!
-e, --extreme # 嘗試通過使用更多的CPU時間來提高壓縮比;
# 要求不影響解壓縮存儲器
-T, --threads=NUM # 最多使用NUM個線程; 默認(rèn)值為1; set to 0
# 設(shè)置為0,使用與處理器內(nèi)核一樣多的線程
-q, --quiet # 抑制警告; 指定兩次以抑制錯誤
-v, --verbose # 冗長; 指定兩次更詳細(xì)
-h, --help # 顯示這個簡潔的幫助并退出
-H, --long-help # 顯示更多幫助(還列出了高級選項(xiàng))
-V, --version # 顯示版本號并退出
壓縮一個文件 20221119test2.txt,壓縮成功后生成 20221119test2.txt.xz, 原文件會被刪除。
xz 20221119test2.txt
解壓20221119test2.txt文件,并使用參數(shù) -k 保持原文件不被刪除。
xz -dk 20221119test2.txt.xz
使用參數(shù) -l 顯示 .xz 文件的基本信息?;拘畔▔嚎s率、數(shù)據(jù)完整性驗(yàn)證方式等。也可以和參數(shù) -v 或 -vv 配合顯示更詳盡的信息。
xz -l 20221119test2.txt.xz
xz -lv 20221119test2.txt.xz
使用參數(shù) -0, -1, -2, … -6, … -9 或參數(shù) –fast, –best 設(shè)定壓縮率。xz 命令的默認(rèn)為 -6 ,對于大多數(shù)系統(tǒng)來說,甚至是一些較舊的系統(tǒng),-4 … -6 壓縮率預(yù)設(shè)值都不錯的表現(xiàn)。
使用參數(shù) -H 顯示 xz 命令所有 options. 參數(shù) -H 比使用參數(shù) –help 顯示的內(nèi)容更詳細(xì)。
借助 xargs 命令并行壓縮多文件。下面的命令行可以將 /var/log 目錄下所有的擴(kuò)展名為 .log 的文件壓縮。通過 xargs 命令同時運(yùn)行多個 xz 進(jìn)行壓縮。
# 運(yùn)行此命令須有 root 權(quán)限。
find /var/log -type f -iname "*.log" -print0 | xargs -P4 -n16 xz -T1
以上就是“l(fā)inux中xz命令怎么使用”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會為大家更新不同的知識,如果還想學(xué)習(xí)更多的知識,請關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。