Linuxlab

tar archives

Updated July 3, 2026

tar gathers a tree of files into one archive, keeping names, permissions and structure.

tar czf a.tar.gz -C ~ project   # create (c), gzip (z), to a file (f)
tar tzf a.tar.gz                # list (t) without extracting
tar xzf a.tar.gz -C ~/restore   # extract (x) into a directory

The letters are easy: c is create, t is list, x is extract; z is gzip, f is file, -C changes directory. tar tzf is handy to peek inside an archive before unpacking.

Used in

You need this in the lesson Archives: tar and gzip.