Back to Cheatsheets

tar

CLI2022-08-11

Reference

{:.-two-column}

Deflate / Inflate / Concatenate

# Deflate / Compress
tar -czf archive.tar.gz /path/files
# Inflate / Uncompress
tar -xzf archive.tar.gz
# Concatenate files into a single tar
tar -cf archive.tar /path/files
# Extract file to a defined directory
tar -xzf archive.tar.gz -C /target/directory
# Append a file to an existing archive
tar -zu archive.tar.gz -C /target/file
# List files in archive
# Add -v for additional details
tar -tzf archive.tar.gz

Common options

OptionDescription
zcompress with gzip
ccreate an archive
uappend files which are newer than the corresponding copy in the archive
ffilename of the archive
vverbose, display what is inflated or deflated
aunlike of z, determine compression based on file extension