Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is a nice command-line trick to tell if a .gz file is really gzipped, as opposed to being a non-Gzip file just named that way?

share|improve this question
up vote 8 down vote accepted

You can use the file command to do this. It will look at the magic numbers in the file and tell you what type it really is.

share|improve this answer
Although it works I feel like there should be a better way. – 7hi4g0 May 21 '14 at 15:10

If it is gzip'd the first two bytes are 0x1F and 0x8B.

To get more complicated than that you will need to understand the file format. See here: and go down to "Member header and trailer" section where you can identify a gzip by its 10 byte header.

share|improve this answer
Interesting info. But it feels like something that were supposed to be on the program with a verify option or something like that. – 7hi4g0 May 21 '14 at 15:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.