OnCallReady

Commands

tar - an archiving utility

tar -c|-x|-t [-v] [-O] [-C DIR] -f ARCHIVE [FILE...]

Options you will use

-c
create an archive
-x
extract files
-t
list the contents
-v
verbose (with -t: mode, owner, size, name)
-f FILE
the archive file
-O
extract to stdout
-C DIR
change to DIR first
-z, --gzip
Filter through gzip: .tar.gz / .tgz.
-j, --bzip2
Filter through bzip2.
-J, --xz
Filter through xz.
-a, --auto-compress
Pick the compression from the archive suffix.
-h, --dereference
Follow symlinks: archive the files they point to, not the links.
-p, --preserve-permissions
Extract the permissions exactly (the default for root).
--exclude=PATTERN
Leave out files matching PATTERN.
-r, --append
Append files to an archive.
--strip-components=N
Drop the first N path components when extracting.
--numeric-owner
Use numeric user and group ids.

Examples

$ tar -tf image.tar

list what docker save produced

$ tar -tvf blobs/sha256/<layer>

list a single layer, whiteouts (.wh.) included

$ tar -xOf blobs/sha256/<layer> app/.env

print one file from a layer

Taught in

Try tar in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.