tar
Transfer and archivesPackage: tar
Bundles a tree into one file, and unpacks it. Without --acls --xattrs it loses ACLs; without -p on extraction, permissions follow your umask rather than the archive.
What its options do in the lessons
From the same glossary the lessons render under their commands, so the two cannot disagree.
tar -x- Extracts the archive’s contents, as opposed to
-c, which creates one. They differ by a single letter, and confusing them overwrites the archive with what you meant to take out of it. tar -z- Runs the archive through gzip on the fly: required for a
.tar.gzfile, pointless for a bare.tar. tar -C- Changes into that directory before extracting, instead of using the current one. It is what lets you extract an archive elsewhere without moving there first.
tar -f- Names the archive file to work on. Without it,
tarreads or writes standard input or output, which is almost never what was meant. tar -c- Creates an archive, as opposed to
-x, which extracts one. A single letter separates them, and confusing them overwrites the archive with what you meant to pull out. tar -t- Lists the archive’s contents without writing anything to disk. It is also the cheapest check that an archive is not truncated: unreadable, it fails here in a second.
tar --acls- Includes POSIX ACLs in the archive, or restores them on extraction. Plain
tarignores them, and a restored tree then comes back with permissions that look right and access that is not. tar --xattrs- Includes extended attributes, which
tarleaves out by default. Same reason as--acls: what is not in the archive does not come back on restore. tar --exclude- Leaves out whatever matches the pattern, written before the source path. An explicit list beats a build directory assumed to be clean: it holds whatever the last thing to write there left behind.
tar --exclude-vcs- Excludes version-control directories —
.gitfirst among them — without having to list them. History has no business in an artefact.
