What does tar do?

archive utility — bundle files into (or extract them from) a .tar.

▸ Explain your own tar command →

tar examples, explained

$ tar -xzvf archive.tar.gz

  • tararchive utility — bundle files into (or extract them from) a .tar
  • -xextract files from an archive
  • -zfilter the archive through gzip (.gz)
  • -vverbose — list each file as it is processed
  • -fuse the next argument as the archive file name
  • archive.tar.gzvalue for -f

$ tar czf backup.tgz src

  • tararchive utility — bundle files into (or extract them from) a .tar
  • ccreate a new archive
  • zfilter the archive through gzip (.gz)
  • fuse the next argument as the archive file name
  • backup.tgzvalue for f
  • srcan argument passed to the command

tar flags & options

-ccreate a new archive
-xextract files from an archive
-tlist the contents of an archive
-rappend files to the end of an archive
-uappend only files newer than the archive copy
-zfilter the archive through gzip (.gz)
-jfilter the archive through bzip2 (.bz2)
-Jfilter the archive through xz (.xz)
-vverbose — list each file as it is processed
-fuse the next argument as the archive file name
-Cchange to the given directory first
-ppreserve file permissions when extracting
-hfollow symlinks — archive the files they point to
-kkeep existing files; don't overwrite when extracting
--createcreate a new archive
--extractextract files from an archive
--listlist the contents of an archive
--gzipfilter the archive through gzip
--bzip2filter the archive through bzip2
--xzfilter the archive through xz
--verboseverbose — list each file as it is processed
--fileuse the given archive file
--excludeskip files matching this pattern
--exclude-fromskip files matching patterns read from this file
--exclude-vcsskip version-control dirs (.git, .svn, …)
--strip-componentsstrip this many leading path parts when extracting

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.