tar
many files into onetar gathers files and directories into one archive, keeping their names, permissions and timestamps. On its own it does not compress — it hands that to gzip or xz — which is why archives are named .tar.gz and .tar.xz.
Three letters do most of it: c creates, x extracts, t lists — and f names the archive file.
At the terminal
Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.
What the numbered lines are telling you
c creates, z compresses with gzip, v is verbose, f names the archive. The paths are stored exactly as shown, starting with "site/".
The archive is an ordinary file. It can be copied, sent over the network or kept as a backup.
Always worth doing first: it shows what the archive will create, and where, before anything is written.
Without it, x unpacks into the current directory. The directory named by -C must already exist.
Switches
A switch changes how the command behaves. These are the ones used day to day; man tar lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.
-c- Create a new archive.
-x- Extract files from an archive.
-t- List the contents of an archive without extracting.
-f FILE- The archive to work on. Nearly every tar command needs it.
-z- Compress or decompress with gzip — the .tar.gz format.
-J- Compress or decompress with xz — smaller, slower. -j is bzip2.
-v- Verbose: print each file as it is added or extracted.
-C DIR- Change to this directory before extracting or adding.
Variations worth knowing
The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.
tar -xf archive.tar.xzExtracts any archive — modern tar works out the compression by itself when reading.
tar -czf etc-$(date +%F).tar.gz /etcMakes a dated backup of a directory, such as etc-2026-09-30.tar.gz.
tar -xzf backup.tar.gz site/index.htmlExtracts a single file from the archive, by its stored path.
tar -czf code.tar.gz --exclude=node_modules project/Leaves a directory out of the archive.
In cybersecurity
An archive is a list of paths that tar will write for you, so one from an untrusted source deserves a look before it is unpacked.
An archive can hold thousands of files with no top directory, or names you did not expect. "tar -tf" shows them first; extract into an empty directory.
As root, tar restores the stored owners and set-uid bits. A hostile archive can then leave a root-owned set-uid program behind.
A tar of /etc or a home directory contains keys and password hashes. Give the archive the permissions the originals had, and encrypt it if it leaves the machine.