42

bzip2 file signature

Magic number at the start of the file · BZh

42 5A 68

bzip2 compressed data begins with the ASCII magic BZh, followed by a single ASCII digit 1 to 9 giving the block size in hundreds of kilobytes. A .tar.bz2 is a tar archive inside a bzip2 stream.

Hex signature
42 5A 68
Offset
0 (start of file)
ASCII
BZh
Length
3 bytes

What this magic number means

A magic number is a short, fixed run of bytes at a known position that tells a program what a file really is, no matter what the filename says. If a file starts with the bytes 42 5A 68 (the text BZh), it is a bzip2 file.

As with gzip, these bytes belong to the compression layer, not to tar. A bare .tar file does not start BZh; a .tar.bz2 or .tbz2 does, because the bzip2 stream is what the file actually begins with. The tar archive only appears once the stream is decompressed.

The digit after BZh is worth reading: BZh9 means 900 KB blocks, the default and the slowest to compress, while BZh1 means 100 KB blocks. It is stored so the decompressor knows how much memory to allocate.

What each byte of 42 5A 68 means

Here is the signature byte by byte, the way a hex editor shows it: the position in the file, the value in hex and in decimal, and the character that value stands for in ASCII. Bytes with no printable character show a dot.

Byte offsetHexDecimalASCII
04266B
15A90Z
268104h

Formats that use the 42 5A 68 signature

No extension in our database is documented under this signature: the bytes belong to the bzip2 format itself, which usually appears as a wrapper around something else. Files that carry it are normally named BZ2, TBZ2.

How to check a file's signature

You can read the bytes of any file yourself. They are shown in hex, the same way this page lists them.

Linux & macOS

  • xxd -l 16 example.bz2
  • hexdump -C -n 16 example.bz2
  • file example.bz2

Windows (PowerShell)

  • Format-Hex -Path example.bz2 -Count 16

Python

  • open("example.bz2","rb").read(3).hex()

In your browser

Frequently asked questions

What is the bzip2 file signature?

bzip2 files start with the hex bytes 42 5A 68 (BZh in ASCII). This magic number identifies the format regardless of the file's name or extension.

How do I check a file's magic number?

Open the file in a hex editor, or run a command such as xxd -l 16 example.bz2 on Linux or macOS, or Format-Hex -Path example.bz2 -Count 16 in Windows PowerShell, and read the first bytes.

Can a file fake the bzip2 signature?

Renaming a file does not change its bytes, so the extension can lie but the signature usually cannot. A genuine bzip2 file has these exact bytes; a file with the wrong bytes is not really bzip2, whatever its name says.

Related signatures

Sources

Reuse this signature

This entry is part of the WhatFileType file signature reference, published under a CC BY 4.0 licence with the full provenance for every entry, a copy-paste embed and a JSON export. Credit WhatFileType and the data is yours to republish.