tar

Archive files and directories, often combined with compression.

Synopsis

tar [options] [archive] [files]

Core Options

-c

Create archive.

-x

Extract archive.

-t

List contents.

-z

gzip compression (.tar.gz).

-J

xz compression (.tar.xz).

-f

Archive file name.

-C dir

Change directory before operation.

Usage Examples

Create gzip archive

Archive a directory.

tar -czf logs.tar.gz ./logs

Extract

Extract into current directory.

tar -xzf logs.tar.gz

List Contents

Inspect archive without extracting.

tar -tf logs.tar.gz

Extract to a Target

Extract into /tmp.

tar -xzf logs.tar.gz -C /tmp
Built for builders.