tar

GNU Tar Cheatsheet #

GNU tar is a widely used version with extensive features and options.

Basic Commands #

Command/OptionExampleDescription
tar -cftar -cf archive.tar file1 file2Create a new archive file (-c for create, -f for file)
tar -xftar -xf archive.tarExtract an archive file (-x for extract, -f for file)
tar -tftar -tf archive.tarList the contents of an archive file (-t for list, -f for file)
tar -czftar -czf archive.tar.gz file1 file2Create a compressed archive with gzip (-z for gzip compression)
tar -xzftar -xzf archive.tar.gzExtract a gzip compressed archive (-z for gzip compression)
tar -cjftar -cjf archive.tar.bz2 file1 file2Create a compressed archive with bzip2 (-j for bzip2 compression)
tar -xjftar -xjf archive.tar.bz2Extract a bzip2 compressed archive (-j for bzip2 compression)
tar -czftar -czf archive.tar.xz file1 file2Create a compressed archive with xz (-J for xz compression)
tar -xJftar -xJf archive.tar.xzExtract an xz compressed archive (-J for xz compression)

Advanced Options #

Command/OptionExampleDescription
tar --appendtar --append -f archive.tar file3Append files to an existing archive (--append option)
tar --deletetar --delete -f archive.tar file1Remove files from an archive (--delete option)
tar -Ctar -cf archive.tar -C /path/to/dir file1Change directory before adding files (-C option)
tar -vtar -cvf archive.tar file1Verbose output showing files being processed (-v option)
tar -ptar -cpf archive.tar file1Preserve file permissions (-p option)
tar --excludetar --exclude='*.tmp' -cf archive.tar *Exclude files matching a pattern from the archive (--exclude option)
tar --transformtar --transform='s/old/new/' -cf archive.tar file1Rename files in the archive (--transform option)
tar -zcvftar -zcvf archive.tar.gz file1Create a gzip compressed archive with verbose output (-z and -v options)

This cheatsheet covers the essential GNU tar commands and options for managing archives.

tar

Explore our comprehensive cheatsheets to enhance your knowledge and efficiency. Each cheatsheet provides detailed command options, examples, and descriptions to help you master various tools and technologies.