Quick Answer: How Do I Compress a Directory in Linux Using Tar?
Contents

How do I compress a folder with tar?

How to compress and extract files using tar command in Linux

  1. tar -czvf name-of-archive.tar.gz /path/to/directory-or-file.
  2. tar -czvf archive.tar.gz data.
  3. tar -czvf archive.tar.gz /usr/local/something.
  4. tar -xzvf archive.tar.gz.
  5. tar -xzvf archive.tar.gz -C /tmp.

How do I zip a directory in Linux tar?

Put a Directory into a TAR file and Compress it with GZIP

Replace FILENAME with whatever filename you want and DIRECTORY with the path to the directory you want to make into a compressed tarball. Tarred files compressed with GZIP sometimes use the . tgz file extension.

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest