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

Looking for Affordable Video Card Recommendations

Hey everyone! I'm considering upgrading my video card from my current Nvidia GeForce GTX 1650. It's holding up, but it struggles with newer games...

Help! My New PC Keeps Restarting Randomly While Gaming

Hey everyone, I just got a new PC about a week ago, and I've been having an issue where it restarts randomly. This has...

Help! Totally Overwhelmed with Upgrading My PC

Hey everyone! I'm reaching out because I've found myself completely lost when it comes to upgrading my pre-built PC that I got back in...

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

OpenAI Token Calculator

This tool is a simple OpenAI token calculator, web-based utility designed to help you quickly estimate the number of tokens in your text when...

List Sorting Tool

Welcome to our innovative list ordering and management tool. This next-level platform enables you to sort a list of items in ascending or descending...

Sudoku Solver

Welcome to our free online Sudoku solving tool, an interactive platform for puzzle enthusiasts seeking a break from a Sudoku conundrum. This advanced platform...

Apply Image Filters To Image

Digital imagery in the modern world is all about reinforcing emotions and stories behind each photo we take. To amplify this storytelling, we are...

Add Watermark To Image

As the world is increasingly consumed by digital media, protecting your original images is paramount. We are thrilled to introduce you to our innovative...

CSV To Xml Converter

Welcome to our CSV to XML converter tool, a convenient and user-friendly solution for all your data conversion needs. This versatile tool on our...

Latest Posts

Latest Questions