- 1Linux Topics Index
- 2How to Create a File in Linux
- 3How to Rename a File in Linux
- 4How to Copy a File in Linux
- 5How to Move a File in Linux
- 6How to Delete a File in Linux
- 7How to Create a Directory in Linux
- 8How to Delete a Directory in Linux
- 9How to Copy Directories Recursively in Linux
- 10Delete Directories Recursively in Linux
- 11How to View Hidden Files in Linux
- 12How to Create a Hidden File in Linux
- 13How to Create a Hidden Directory in Linux
- 14How to Find Files in Linux Using find Command
- 15Find Files in Linux Using locate Command
- 16How to View File Contents Using cat in Linux
- 17How to View File Contents Using less in Linux
- 18View File Contents Using the more Command in Linux
- 19Compare Files Using diff Command in Linux
- 20Compare Files in Linux Using cmp Command
- 21Check File Type in Linux with file Command
- 22Create Symbolic Links with ln -s in Linux
- 23How to Archive Files Using tar Command in Linux
- 24Compress Files with gzip in Linux – Beginner Tutorial
- 25How to Compress Files Using bzip2 in Linux
- 26Compress Files in Linux Using zip Command
- 27Extract Compressed Files using tar in Linux
- 28Extract ZIP Files on Linux with unzip
- 29How to Extract .gz Files using gunzip in Linux

- 1Linux Topics Index
- 2How to Create a File in Linux
- 3How to Rename a File in Linux
- 4How to Copy a File in Linux
- 5How to Move a File in Linux
- 6How to Delete a File in Linux
- 7How to Create a Directory in Linux
- 8How to Delete a Directory in Linux
- 9How to Copy Directories Recursively in Linux
- 10Delete Directories Recursively in Linux
- 11How to View Hidden Files in Linux
- 12How to Create a Hidden File in Linux
- 13How to Create a Hidden Directory in Linux
- 14How to Find Files in Linux Using find Command
- 15Find Files in Linux Using locate Command
- 16How to View File Contents Using cat in Linux
- 17How to View File Contents Using less in Linux
- 18View File Contents Using the more Command in Linux
- 19Compare Files Using diff Command in Linux
- 20Compare Files in Linux Using cmp Command
- 21Check File Type in Linux with file Command
- 22Create Symbolic Links with ln -s in Linux
- 23How to Archive Files Using tar Command in Linux
- 24Compress Files with gzip in Linux – Beginner Tutorial
- 25How to Compress Files Using bzip2 in Linux
- 26Compress Files in Linux Using zip Command
- 27Extract Compressed Files using tar in Linux
- 28Extract ZIP Files on Linux with unzip
- 29How to Extract .gz Files using gunzip in Linux

- 1How to Add a New User in Linux
- 2Modify Existing User in Linux
- 3Delete a User in Linux — Step-by-Step for Beginners
- 4Create a User Group in Linux - Step-by-Step Tutorial
- 5Linux: Add User to Group
- 6How to Remove a User from a Group in Linux
- 7Delete a User Group in Linux - Beginner Friendly Tutorial
- 8Linux su Command Tutorial – Switch Users Easily
- 9Linux sudo Command - Execute as Another User
- 10Change a User's Password in Linux Using passwd
- 11Set Password Expiry in Linux using chage
- 12Lock a User Account in Linux
- 13How to Unlock a User Account in Linux
- 14Configure User Login Shell in Linux
- 15How to Configure User Environment Variables in Linux
- 16Edit .bashrc and .profile in Linux - User Startup Files Tutorial
How to Extract Compressed Files using tar Command
Next Topic ⮕Extract ZIP Files on Linux with unzip
How to Extract Compressed Files using the tar
Command in Linux
Hey there, and welcome to this hands-on Linux tutorial from ProgramGuru.org! 👋
Today, we're going to walk through one of the most common tasks every Linux user faces — extracting compressed files using the tar
command.
We’ll look at how to handle different archive formats like:
.tar
– just an archive, no compression.tar.gz
or.tgz
– archive + gzip compression.tar.bz2
– archive + bzip2 compression
Let’s get started!
🛠️ 1. Extracting a .tar file
Imagine you’ve downloaded a file called project.tar
. This file is just a collection of files bundled together without compression.
To extract it, run:
tar -xvf project.tar
Let’s break it down:
-x
means extract-v
stands for verbose (shows progress)-f
specifies the file name to work with
Here's what the output might look like:
file1.txt
file2.txt
images/
images/logo.png
🛠️ 2. Extracting a .tar.gz or .tgz file
These files are archived and compressed using gzip. The command is just as simple:
tar -xvzf project.tar.gz
Or if the file is named project.tgz
:
tar -xvzf project.tgz
Here’s the output:
project/
project/main.cpp
project/README.md
And again, here’s what the options mean:
-z
tellstar
to use gzip-xvzf
is the usual combo to extract and see progress
🛠️ 3. Extracting a .tar.bz2 file
If your file uses bzip2 compression, like project.tar.bz2
, you’ll need to use the -j
flag:
tar -xvjf project.tar.bz2
That tells tar to use bzip2 while extracting.
project/
project/index.html
project/style.css
📁 Optional: Extract to a Specific Directory
Want to extract files to a custom folder? Use the -C
option:
tar -xvzf project.tar.gz -C /home/yourname/projects/
✅ Summary
Here’s a quick cheat sheet:
tar -xvf file.tar
– extract .tartar -xvzf file.tar.gz
– extract .tar.gz or .tgztar -xvjf file.tar.bz2
– extract .tar.bz2
And that’s it! You've now mastered the basics of extracting compressed files using tar
in Linux.
Thanks for learning with us at ProgramGuru.org. If this was helpful, be sure to check out our other beginner-friendly Linux guides. 🚀