When I run:
tar -zxvf john-1.7.0.2.tar.gz
I get this:
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
It should start unpacking.
Some people told me not to use the z
but I get the same error.
It's a file that I downloaded this way:
wget http://openwall.com/john/f/john-1.7.0.2.tar.gz
Best Answer
Diagnosing a Downloaded File of the Wrong Type
As steeldriver says, this means the file isn't really a gzipped tar file -- or any kind of gzipped file -- in spite of being named like one.
When you download a file with
wget
, there are often indications that you've ended up getting a different kind of file than what you were looking for:In this case, the main signs are:
301 Moved Permanently
message, redirecting to an address with a trailing/
. This loads the default page for some directory on the server, which is usuallyindex.html
and almost always an HTML file.Length: unspecified [text/html]
, telling you that you're receiving plain text (text
) and that it is intended to be interpreted ashtml
. This is really more than a sign -- you can be pretty sure you haven't gotten a real gzipped file based on this.You can also use the
file
utility, which examines a file and tells you what kind of file it looks to be:And of course you can examine the file yourself, with tools such as
head
,less
, andview
:If this were really a binary file, then you would've gotten a whole bunch of meaningless garbage instead, as whatever pager or viewer your use fruitlessly attempts to interpret something as plain text that really isn't. For example, on the correct file:
(I've only copied the very beginning of that.)
Getting the Right File
That tells you how to figure out what went wrong in these situations (and in this case, in particular). But how do you actually find and download the correct file?
This varies from situation to situation. However, a good start is to:
Go to the official website for the software and see if they provide download links. Even if that's how you got the link you're using originally, if some time has passed you may find that the link has changed.
For example, in this particular case, the current version is 1.8.0 instead of 1.7.0.2 (and provided in the
j
subdirectory instead off
), and the old version is no longer available at that same URL.Go to the page that you were redirected to when you downloaded the file. In this case, that's: http://www.openwall.com/john/
Or you can even examine the file that was downloaded. (Or open it in a web browser.)
You got redirected to the software's main download page. You can either download in a web browser, or copy a correct current download link and download it with
wget
. There are a few choices, but assuming you don't actually need that specific old version you were trying to download, and based on the specific file you did attempt to download, I suspect http://openwall.com/john/j/john-1.8.0.tar.gz is what you are looking for.Of course, readers who find this post later may find that link no longer works. But the approach demonstrated here for troubleshooting this sort of problem will remain valid.
I've downloaded the file. Notice that, this time, no undesired redirection happened and the type is given as
application/x-tar
instead oftext/html
.(An HTTP redirection is not always bad. It's when you get redirected to something that doesn't seem like it could really be the file you're looking for that you should suspect your download has not really succeeded.)
file
agrees:And it unpacks successfully:
(You are right that it doesn't matter if you use the
z
; it would still have worked withtar xzf
, since this is the correct file.)You can proceed to build the source code and install.
Remember, You Don't Always Have to Build From Source
Sometimes you really want the latest version of a program, and it's not in Ubuntu's repositories. You might try to find a PPA, but if you don't find any you really trust or that provide quite what you want, or you want to build it with custom options, or you just really like building from source code, then building from source code is a valuable and useful technique.
I do recommend checking at least the software that is available in Ubuntu's official repositories for your system, though. On my 16.04 system:
There are several other ways to search for packages. Often it's handy to use the Ubuntu Packages Search web page.
Since you were going to attempt to install version 1.7.0.2, presumably version 1.8.0 in the official repositories is recent enough. (Indeed, 1.8.0 seems to be the same version as the one provided for download from the official website.) So you really might just want to install that: