Extract a .tar.gz archive with tar
Unpack a gzipped tarball into the current directory while printing each file as it is extracted.
01Command
$ tar -xvzf archive.tar.gz02What it does
The flags are x (extract), v (verbose), z (gzip decompression), f (file follows). GNU tar detects compression automatically, so tar -xf archive.tar.gz also works, and the same command handles .tar.bz2, .tar.xz, and plain .tar. To extract into a specific directory use -C: tar -xzf archive.tar.gz -C /tmp/dest. List contents first with tar -tzf archive.tar.gz to check whether the archive contains a single top-level folder or will splatter files into the current directory.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- tar(1) — an archiving utilityEvidence: The tar man page documents -x to extract, -z to filter through gzip, -v for verbose listing, and -f to specify the archive file.
Last verified: 2026-09-17 · Category: Files & Folders
06Related solutions
Find every occurrence of a pattern across all files in a tree, printed as file:line:number matches.
Add or remove read, write, and execute permission for the owner, group, or others using symbolic or octal modes.
Refresh the package index from all configured repositories, then install newer versions of every upgradable package.