xz
is a popular command-line utility in Linux used for compressing and decompressing files using the LZMA (Lempel-Ziv-Markov chain algorithm). It is known for providing high compression ratios, making it suitable for compressing large files.
Here are some common commands to use xz
:
xz filename
This command will compress filename
and create a new file named filename.xz
. The original file will be deleted by default.
xz -d filename.xz
or
unxz filename.xz
This will decompress the filename.xz
file back to filename
.
If you want to keep the original file after compression, you can use the -k
option:
xz -k filename
You can set the compression level with the -0
(no compression) to -9
(maximum compression):
xz -9 filename
You can view all available options for xz
by running:
xz --help
xz
is often used in conjunction with tar
to create compressed archives:tar -cJf archive.tar.xz directory/
This command will create a compressed archive of directory
named archive.tar.xz
.
xz
is installed on your system. You can usually install it using your package manager, for example:sudo apt-get install xz-utils # For Debian-based systems
sudo yum install xz # For Red Hat-based systems