Extracting TAR GZ Archives Via Command Line

This tutorial will show you how to zip up a folder as a tar.gz then extract the contents of a tar.gz. First start by going to the directory that contains the file that you want to compress. For demonstration purposes I will create a new folder and zip it up. Then delete the folder and unzip it to show the process working.

Step 1

To make this tutorial easier you should cd to the directory that contains the folder that you want to zip. e.g cd /tmp

To compress the folder we will use the tar command. You will then provide the name that you want to use for the archived file/folder and the name of the file/folder you want to archive.

 

tar -pczf zippedarchive.tar.gz zipme

Step 2

Use ls to check that the process was successful. You should see your newly created archive listed on the screen. You have successfully created a tar.gz archive! Now let us unzip it.

Step 3

Start by removing the old directory that we just zipped up.In this case I want to delete the directory called delete zipme. Use rmdir /zipme to delete the directory and use ls to check that is has successfully been deleted. Now you can extract the archive.
To Extract a tar.gz archive you can use the tar command again.

[root tmp]# tar xvsf zippedarchive.tar.gz

Use ls to check that the directory was successfully extracted. Below is the full process of creating a directory, archiving it, then extracting it with validation steps in between.

[root tmp]# mkdir zipme
[root tmp]# ls
zipme
[root tmp]# tar -pczf zippedarchive.tar.gz zipme
[root tmp]# ls
zipme zippedarchive.tar.gz
[root tmp]# rmdir zipme
[root tmp]# ls
zippedarchive.tar.gz
[root tmp]# tar xvsf zippedarchive.tar.gz
zipme/
[root tmp]# ls
zipme zippedarchive.tar.gz

Related Articles

Related Questions

Is There a Real Difference Between 3200MHz and 3600MHz DDR4 RAM?

I'm currently using 32GB of 3600MHz RAM with a Ryzen 3700x CPU, but I'm looking to upgrade since I'm often hitting the 20-22GB range...

What’s the context window size for Claude 4?

I'm curious about the context window size for Claude 4. I couldn't find much information on it and would love to know if anyone...

What Alternatives to VMWare Are People Exploring?

I'm curious about the current trends in virtualization solutions. Has anyone conducted any polls or gathered insights on what options users are replacing VMWare...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Tools

Online Hash Generator – String to Hash Converter

Need to quickly generate a hash from a string? Whether you're verifying file integrity, securing data, or just experimenting with cryptographic tools, this simple...

Convert CSV To HTML Table

Need to quickly turn CSV data into an HTML table? Whether you're copying data from Excel, Google Sheets, or another spreadsheet, this tool makes...

Student Group Randomizer

Creating fair and balanced groups in the classroom can be time-consuming — especially when you're trying to avoid repetition, manage different skill levels, or...

Random Group Generator

Need to split a list of people, items, or ideas into random groups? Our free Random Group Generator makes it quick and easy. Whether...

Flip Text Upside Down – Free Online Tool

Ever wanted to flip your text upside down just for fun or to grab someone’s attention in a creative way? This free online Upside...

Raffle Ticket Generator

If you're running a fundraiser, charity draw, or local event and need raffle tickets fast, this free online tool lets you generate and print...

Latest Posts

Latest Questions