How to Extract Compressed File in an tar.xz format using a Command in Linux Comand Line

Posted on

Introduction

This is a specific article for showing how to extract compressed file in a certain format. The format file is in tar.xz. It is a compressed file format. The compression file with that specific format is also known as tarball. There is a detail information about the name of it, as it is part of the compression format, the ‘tar’ name. According to the Wikipedia page, tar is a computer software utility for collecting many files into one archive file, often referred to as a tarball, for distribution or backup purposes. The name is derived from (t)ape (ar)chive, as it was originally developed to write data to sequential I/O devices with no file system of their own.

The archive data sets created by tar contain various file system parameters, such as name, time stamps, ownership, file access permissions, and directory organization. The command line utility was first introduced in the Version 7 Unix in January 1979, replacing the tp program. Furthermore, according to the Wikipedia, the file structure to store this information was standardized in POSIX.1-1988 and later POSIX.1-2001, and became a format supported by most modern file archiving systems. According to the manual page of ‘tar’, it is an archiving utility.

 

Extracting file using the ‘tar’ utility or command

The following is the command for extracting the compressed file with the format of ‘tar.xz’ :

tar xvf file_name.tar.xz
tar : the command, the utility or the program 
x : extract action, it is one of the available operation mode
v : display and print the output of the process or verbosely list file processed
f : device selection to specify the file name for further extraction
file_name.tar.xz : the file name passed to the command utility for further extraction

The example for the above command pattern execution exist as follows :

root@hostname ~# tar xvf files.tar.xz 
...
root@hostname ~#

After successfully installing the package, the compressed file is possible for further extraction. By default, the ‘tar’ command or utility is available in the operating system. But the format of ‘.tar.xz’ for furthere extraction need some package to be exist in the operating system.

There is a certain prerequisite for executing the extraction command for the compressed file. In this context, a compressed file with the .tar.xz extension. The command extraction for the .tar.xz file format must have an xz-utils installed in the machine. Apparently, it is a requirement in Linux Ubuntu 18.04 but actually, it assumes that the requirement is for Linux or Unix operating system in general. Check the package first to retrieve the correct information about xz-utils package :

root@hostname ~# apt-cache search xz-utils
devscripts - scripts to make the life of a Debian Package maintainer easier
xz-utils - XZ-format compression utilities
pixz - parallel, indexing XZ compressor/decompressor
xzdec - XZ-format compression utilities - tiny decompressors
root@hostname ~# 

There is another way for checking the availability of the package with the name of ‘xz-utils’. It is by executing the following command :

root@hostname ~# apt list --installed | grep xz-utils
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
xz-utils/bionic,now 5.2.2-1.3 amd64 [installed,automatic]
root@hostname ~# 

Leave a Reply