Guides

Essential Linux commands for file compression and extraction.
Linux Guides

Compress and Extract tar and tar.gz

Simple commands to archive and extract files in Linux.

1. Create tar archive

tar -cvf file.tar dir

2. Extract tar archive

tar -xvf file.tar

3. Create tar.gz archive

tar -zcvf file.tar.gz dir

4. Extract tar.gz archive

tar -zxvf file.tar.gz

About this guide

This guide shows how to compress and extract files using tar and tar.gz in Linux.

How to follow this guide

  1. Use tar to create archive files.
  2. Extract tar files.
  3. Use gzip with tar to compress smaller files.
  4. Extract tar.gz files.

Why use this method?

tar and gzip are standard tools used in Linux for packaging and compressing files efficiently.

Frequently Asked Questions

What is tar?

tar is a tool used to archive multiple files into a single file.

What is tar.gz?

It is a tar archive compressed with gzip.

What does -z mean?

It enables gzip compression.

Can I extract specific files?

Yes, tar supports extracting specific files using additional options.

Related Tools