xz in Linux is a command used to compress and decompress system files. After the compression is completed, the system will automatically add the ".xz" extension to the original file and delete the original file; the xz command can only Compress files, not directories.
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
What is the xz command in Linux?
Detailed explanation of xz command usage in Linux system (compression and decompression)
xz command: POSIX platform development has high Compression tool. It uses the LZMA2 compression algorithm, and the compressed files generated are smaller than the compressed files generated by gzip and bzip2 traditionally used by the POSIX platform, and the decompression speed is also very fast, compressing or decompressing xz files.
Function description:
xz command will compress and decompress system files. After the compression is completed, the system will automatically add the .xz extension to the original file and delete the original file. The xz command can only compress files, not directories.
Syntax structure:
xz(选项)(参数) 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> (in English or Finnish). XZ Utils home page: <http:></http:></lasse.collin>
-z, --compress # 强制压缩 -d, --decompress, --uncompress # force decompression -t, --test # 测试压缩文件的完整性 -l, --list # 列出有关.xz文件的信息 -k, --keep # 保留(不要删除)输入文件 -f, --force # 强制覆盖输出文件和(解)压缩链接 -c, --stdout, --to-stdout # 写入标准输出,不要删除输入文件 -0 ... -9 # 压缩预设; 默认为6; 取压缩机*和* # 使用7-9之前解压缩内存使用量考虑在内! -e, --extreme # 尝试通过使用更多的CPU时间来提高压缩比; # 要求不影响解压缩存储器 -T, --threads=NUM # 最多使用NUM个线程; 默认值为1; set to 0 # 设置为0,使用与处理器内核一样多的线程 -q, --quiet # 抑制警告; 指定两次以抑制错误 -v, --verbose # 冗长; 指定两次更详细 -h, --help # 显示这个简洁的帮助并退出 -H, --long-help # 显示更多帮助(还列出了高级选项) -V, --version # 显示版本号并退出
Compress a file 20221119test2.txt. After successful compression, 20221119test2.txt.xz will be generated. The original file will be deleted.
xz 20221119test2.txt
Decompress the 20221119test2.txt file and use the parameter -k to keep the original file from being deleted.
xz -dk 20221119test2.txt.xz
Use the parameter -l to display the basic information of the .xz file. Basic information includes compression rate, data integrity verification method, etc. It can also be used with the parameter -v or -vv to display more detailed information.
xz -l 20221119test2.txt.xz xz -lv 20221119test2.txt.xz
Use parameters -0, -1, -2, … -6, … -9 or parameters –fast, –best to set the compression rate. The default of the xz command is -6, and for most systems, even some older systems, the -4 ... -6 compression ratio presets work well.
Use the parameter -H to display all options of the xz command. The parameter -H is more detailed than the content displayed using the parameter -help.
Use the xargs command to compress multiple files in parallel. The following command line can compress all files with a .log extension in the /var/log directory. Run multiple xz at the same time for compression through the xargs command.
# 运行此命令须有 root 权限。 find /var/log -type f -iname "*.log" -print0 | xargs -P4 -n16 xz -T1Related recommendations: "Linux Video Tutorial"
The above is the detailed content of What is the xz command in linux?. For more information, please follow other related articles on the PHP Chinese website!

MaintenanceModeinLinuxisaspecialbootenvironmentforcriticalsystemmaintenancetasks.Itallowsadministratorstoperformtaskslikeresettingpasswords,repairingfilesystems,andrecoveringfrombootfailuresinaminimalenvironment.ToenterMaintenanceMode,interrupttheboo

The core components of Linux include kernel, file system, shell, user and kernel space, device drivers, and performance optimization and best practices. 1) The kernel is the core of the system, managing hardware, memory and processes. 2) The file system organizes data and supports multiple types such as ext4, Btrfs and XFS. 3) Shell is the command center for users to interact with the system and supports scripting. 4) Separate user space from kernel space to ensure system stability. 5) The device driver connects the hardware to the operating system. 6) Performance optimization includes tuning system configuration and following best practices.

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

Linux maintenance mode can be entered through the GRUB menu. The specific steps are: 1) Select the kernel in the GRUB menu and press 'e' to edit, 2) Add 'single' or '1' at the end of the 'linux' line, 3) Press Ctrl X to start. Maintenance mode provides a secure environment for tasks such as system repair, password reset and system upgrade.

The steps to enter Linux recovery mode are: 1. Restart the system and press the specific key to enter the GRUB menu; 2. Select the option with (recoverymode); 3. Select the operation in the recovery mode menu, such as fsck or root. Recovery mode allows you to start the system in single-user mode, perform file system checks and repairs, edit configuration files, and other operations to help solve system problems.

The core components of Linux include the kernel, file system, shell and common tools. 1. The kernel manages hardware resources and provides basic services. 2. The file system organizes and stores data. 3. Shell is the interface for users to interact with the system. 4. Common tools help complete daily tasks.

The basic structure of Linux includes the kernel, file system, and shell. 1) Kernel management hardware resources and use uname-r to view the version. 2) The EXT4 file system supports large files and logs and is created using mkfs.ext4. 3) Shell provides command line interaction such as Bash, and lists files using ls-l.

The key steps in Linux system management and maintenance include: 1) Master the basic knowledge, such as file system structure and user management; 2) Carry out system monitoring and resource management, use top, htop and other tools; 3) Use system logs to troubleshoot, use journalctl and other tools; 4) Write automated scripts and task scheduling, use cron tools; 5) implement security management and protection, configure firewalls through iptables; 6) Carry out performance optimization and best practices, adjust kernel parameters and develop good habits.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.