How to Decompress .xz Files in Ubuntu Terminal
This article provides a straightforward guide to decompressing .xz files within the Ubuntu command line interface. It covers the primary commands required to extract data, options to retain the original archive, and methods for processing multiple files at once. By following these instructions, you can efficiently manage compressed files on your Linux system.
Install Required Tools
The xz-utils package is typically pre-installed on
Ubuntu. If the terminal returns a command not found error, install it
with:
sudo apt install xz-utilsUse the Unxz Command
To decompress a file, type unxz followed by the file
name. This extracts the data and deletes the original .xz archive.
unxz file.txt.xzYou can also use the xz command with the -d
option for the same result:
xz -d file.txt.xzKeep the Original Archive
Add the -k flag if you need to preserve the compressed
file after extraction.
unxz -k file.txt.xzProcess Multiple Files
Use an asterisk wildcard to decompress every .xz file in the current directory simultaneously.
unxz *.xzCheck the directory with ls to confirm your files have
been extracted successfully.