How to decompress a .tar.xz file? - linux

There is a file having an extension .tar.xz : wkhtmltox-linux-i386_0.12.0-03c001d.tar.xz
What is the linux command to uncompress it ?

From the Ubuntu Site here.
tar -xJf wkhtmltox-linux-i386_0.12.0-03c001d.tar.xz

If you have a recent version of tar (1.25 or later), you should be able to just type:
tar xf wkhtmltox-linux-i386_0.12.0-03c001d.tar.xz
And it will correctly determine what type of decompression to use.
In addition, you can use tar caf archive.ext files_to_add to create archives, and it will decide which compression algorithm to use based on the extension of the archive.

The -J, --xz flags are for that:
tar -xJf file.pkg.tar.xz
You can also use the xz-utils package and use the unxz command on the file, then use standard tar from there.

Related

tar package has different checksum for exactly the same content

Packaging a folder on a SUSE Linux Enterprise Server 12 SP3 system using GNU tar 1.30 always gives different md5 checksums although the file contents do not change.
I run tar to package my folder that contains a simple text file:
tar cf package.tar folder
Nevertheless, although the content is exactly the same, the resulting tar always has a different md5 (or sha1) checksum:
$> rm -rf package.tar && tar cf package.tar folder && md5sum package.tar
e6383218596fffe118758b46e0edad1d package.tar
$> rm -rf package.tar && tar cf package.tar folder && md5sum package.tar
1c5aa972e5bfa2ec78e63a9b3116e027 package.tar
Because the linux file system seems to deliver files in a random order to tar, I tried using the --sort option. But the resulting command doesn't change the checksum issue for me. Also tar's --mtime option does not help here, since the creation dates are exactly the same.
I appreciate any help on this.
The archives you provided contain pax extended headers.
A quick glance at their structure reveals that they differ in these two fields:
The process ID of the pax process (as part of a name for the extended header in the ustar header block, and consequently the checksum for this ustar header block).
The atime (access time) in the extended header.
One of the workarounds you can use for reproducible archive creation is to enforce the old unix ustar format (rather than the pax/posix format):
tar --format=ustar -cf package.tar folder
The other choice is to manually set the extended name and delete the atime while preserving the pax format:
tar --format=pax --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime -cf package.tar folder
Now the md5sum should be the same for both archives.
The header for tar files contain several fields which will be potentially different each time you re-tar a set of files. For instance the last access time and modification time will likely be different each time.
According to this article it is possible with GNU tar to produce identical output for identical input by doing the following:
# requires GNU Tar 1.28+
$ tar --sort=name \
--mtime="2018-10-05 00:00Z" \
--owner=0 --group=0 --numeric-owner \
-cf product.tar build
tar -p --sort=name --no-acls --no-selinux --no-xattrs
worked for a similar situation in slackware 14.2, using
GNU tar 1.29.
The p stands for preserve attributes (owner and time) and is assumed for a root user.
Also consider untarring with --atime-preserve (depending on purpose).

Use tar to archive the contents of your home directory in linux

I am trying to archive the contents of my home directory using tar and then compress the tar file with gzip. I know you can uncompress and unarchive the .tar.gz file using cat, tar and gzip. But , I don't know how to compress and archive.
Hey there here is a link for your question. a full guide
https://www.howtogeek.com/248780/how-to-compress-and-extract-files-using-the-tar-command-on-linux/
tar -czvf name-of-archive.tar.gz /path/to/directory-or-file
Here’s what those switches actually mean:
-c: Create an archive.
-z: Compress the archive with gzip.
-v: Display progress in the terminal while creating the archive, also known as “verbose” mode. The v is always optional in these commands, but it’s helpful.
-f: Allows you to specify the filename of the archive.

Which tar options do I need to install node from binary on linux?

Background
I downloaded binary for linux 64-bit and I was following several tutorials, each with similar options:
tar -C /usr/local --strip-components 1 -xzf /path/to/node.tar.gz
I always get this error:
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
I've googled and it seems I have manually specified gzip file format via one of these switches. File is actually tar.xz, not tar.gz. It was probably tar.gz in older versions.
I wonder what do all of these options mean and which one's I need?
Is there an auto-detect format option?
This is what running info tar said:
-C, --directory DIR
change to directory DIR
--strip-components=NUMBER
strip NUMBER leading components from file names on extraction
-x, --extract, --get
extract files from an archive
-z, --gzip, --gunzip --ungzip
-f, --file ARCHIVE
use archive file or device ARCHIVE
Questions
I don't understand options -f, --strip-components.
-f - What else can it be but a file? What is "device archive"?
--strip-components - What does --strip-components 1 exactly do here?
I don't see any numbers in the file.
Please provide example of filename which would be affected by --strip-components and explain how.
And what's the idea with installing nodejs on linux?
Just unzip to /usr/local or what else needs to be done?
First, tar is "smart" enough to detect the compression method used in an archive so it isn't necessary to specify -z or -j.
-f - What else can it be but a file? What is "device archive"?
A device archive could be a tape archive attached to your machine in /dev/your_tar
--strip-components - What does --strip-components 1 exactly do
tar xfz /var/www/site/site.gz --strip-components=2
will create /var/site.

How create tgz archive file in windows?

How can I create myData.tgz in Windows?
I need my data in tgz Archiv format in windows 10
but I dont know how can ?
I know how create tar.gz Archiv,but .tgz I dont know
tgz is simply a different spelling for tar.gz. If you rename your file.tar.gz to file.tgz, you are done.
You can follow the same procedure as in Linux Environment using CMD, PowerShell, or Git Bash, etc...
Compression using tar:
tar -cvzf <name of tarball>.tgz path/to/source/folder
for example, the command to compress a folder sample in my current directory to a file backup.tgz:
tar -cvzf backup.tgz sample
For more refer to the documentation of tar command

Untar a file on Solaris reports - tar: directory checksum error

Hi I am trying to untar a compressed file on a Solaris server. I run the command
tar xvf 4.56_release.tar.gz
But this reports the following error
tar: directory checksum error
Initially I thought it was a bad download so I re-downloaded the file (actually a different version) and it reports the same error.
Un-compressing and un-tar'ing it on Linux on a Linux server works fine.
Any ideas what I am doing wrong.
The .tar.gz is the hint for what you are doing wrong - you are not uncompressing it first. If your version of tar supports it, you can use the -z flag to specify it is compressed with gzip:
tar -xzvf 4.56_release.tar.gz
Otherwise, you'll have to gunzip it manually:
gunzip -c 4.56_release.tar.gz | tar xvf -
(The reason it works on Linux is probably that is has a newer/different version which automagically detects the compression)
If you have a '.tar.bz2' type of archive file and neither of the above options worked ('-z' is not supported for your version of 'tar'), you can use:
bzip2 -d your_file.tar.bz2
to decompress, then use tar:
tar -xvf your_file.tar
Taken from here: https://www.linuxquestions.org/questions/solaris-opensolaris-20/how-to-unpack-a-tar-bz2-file-654772/
Solaris tar automatically detects if the tar file is compressed or not, as does Linux. But older versions of Solaris and Linux do not do this. For Solaris, I think it needs to be Solaris 11 or greater to automatically detect compressed files. Otherwise use the tar -z option.

Resources