tar -x: Extract an Archive (Usage & CI Errors)
tar -x unpacks the members of an archive back onto disk.
Extracting is the consumer side of caching and downloads. The flags decide where files land and whether decompression is automatic.
What it does
tar -x (extract) reads an archive and writes its members into the current directory, recreating the stored directory tree. Modern GNU and BSD tar auto-detect gzip, bzip2, xz, and zstd, so -z is usually optional on extract.
Common usage
tar -xf archive.tar
tar -xvf archive.tar.gz # verbose, auto-decompress
tar -xf archive.tar -C /opt/app # extract into a target dir
tar -xzf archive.tar.gz path/to/one/file # extract a single memberOptions
| Flag | What it does |
|---|---|
| -x / --extract | Extract members from the archive |
| -f <file> | Read from <file> instead of stdin (use - for stdin) |
| -C <dir> | Change to <dir> before extracting |
| -v / --verbose | List each file as it is extracted |
| --strip-components=N | Remove N leading path components |
In CI
Extracting a downloaded release is a tar -x step: curl -L url | tar -xz -C /usr/local/bin --strip-components=1 streams the download, decompresses it, and drops the binary into place without the versioned top-level folder.
Common errors in CI
gzip: stdin: not in gzip format means you passed -z to a file that is not gzip-compressed (often a plain .tar or an HTML error page saved as a .tar.gz). Drop -z or fix the download. tar: Unexpected EOF in archive and tar: short read mean the archive is truncated, usually a partial or failed download; re-fetch and verify the size or checksum.