How to Un-Compress or Extract and Compress tar Files in Linux?

If xz-utils is not installed in your Debian or Ubuntu machine use the following command to install the utilities.

sudo apt-get install xz-utils

Extracting tar.gz or tar.xz file in linux

tar -xf archive.tar.xz

In order to print the list of files

tar -xf archive.tar.xz

In order the extract the files in specific location

tar -xf archive.tar.xz -C /home/app/files

In order the extract the files in the multiple location

tar -xf archive.tar.gz dir1 dir2

Listing tar.gz file

tar -tf archive.tar.gz

If you add the –verbose (-v) option, tar will print more information, such as owner, file size, time stamp etc..

tar -tvf archive.tar.gz

In order to create archive files follow the following commands.

 tar -cJf archive.tar.xz folder/

Leave a Reply

Your email address will not be published.Required fields are marked *