Ugacomp

How to Extract Compressed Files on Linux

Where necessary, you may need to have access to a VPS server so you can follow how to implement the steps in this article.  You can get a cheaper VPS Server from Contabo with 4vCPU cores, 8GM RAM, and 32TB Bandwidth for less than $5.50 per month. Get this deal here now

Table of Contents

Cloud VPS S

$5.50 Monthly
  • 4 vCPU Cores | 8GB RAM

CLOUD VPS M

$15.50 Monthly
  • 6 vCPU Cores | 16GB RAM

CLOUD VPS L

$17.50 Monthly
  • 8 vCPU Cores | 24GB RAM

Linux provides a powerful set of command-line tools for managing files and archives. One common task is extracting compressed files, and this can be accomplished using various commands. In this article, we’ll explore the commands and examples for extracting compressed files on a Linux system.

Method #1: Using Tar Command

The tar command is a standard utility in most Linux distributions, and it is usually pre-installed. However, if, for some reason, it’s not available on your system or you want to make sure you have the latest version, you can install it using the package manager specific to your Linux distribution.

For Debian/Ubuntu-based Systems

sudo apt-get update
sudo apt-get install tar

For Red Hat/Fedora-based Systems

sudo yum install tar

For openSUSE-based Systems

sudo zypper install tar

For Arch Linux

sudo pacman -S tar

Once installed, you can verify that tar is available by checking its version:

tar --version

If the installation was successful, you’ll see information about the installed tar version. Now you can use the tar command to manage archives on your Linux system.

To extract a compressed file, use the following syntax

tar -xf file.tar.gz

Replace file.tar.gz with the actual name of your compressed file. Here’s a breakdown of the options:

  • -x: Extract files.
  • -f: Specify the archive file.

Extracting Bzip2 Files

If your file is compressed using Bzip2, you can use the tar command with the -j option. Here’s an example:

tar -xjf file.tar.bz2

Replace file.tar.bz2 with your specific Bzip2-compressed file. The -j option tells tar to handle Bzip2 compression.

Method #2: Extracting Zip Files with Unzip

If the unzip command is not already installed on your Linux system, you can install it using the package manager specific to your distribution. Here are the commands for various Linux distributions:

For Debian/Ubuntu-based Systems:.

sudo apt-get update
sudo apt-get install unzip

For Red Hat/Fedora-based Systems:

sudo yum install unzip

For openSUSE-based Systems:

sudo zypper install unzip

For Arch Linux:

sudo pacman -S unzip

Once the installation is complete, you can verify that unzip is available by checking its version:

unzip -v

If the installation was successful, you’ll see information about the installed unzip version. Now you can use the unzip command to extract contents from Zip archives on your Linux system.

unzip file.zip

Replace file.zip with the name of your Zip file. The unzip command extracts the contents of the specified Zip archive.

Method #3: Using Gunzip for Gzip Files

gunzip is actually not a separate command but a decompression tool that is often used in conjunction with the tar command to handle Gzip-compressed files. Gzip compression is commonly used in Linux for compressing individual files.

The gzip command is usually pre-installed on most Linux systems. If it’s not available for some reason, you can install it using the package manager specific to your distribution.

For Debian/Ubuntu-based Systems:

sudo apt-get update
sudo apt-get install gzip

For Red Hat/Fedora-based Systems:

sudo yum install gzip

For openSUSE-based Systems:

sudo zypper install gzip

For Arch Linux:

sudo pacman -S gzip

After installing gzip, you can use it to decompress Gzip-compressed files. For example:

gzip -d file.gz

Replace file.gz with the actual Gzip-compressed file you want to decompress. The -d option stands for “decompress.”

Keep in mind that the gunzip command is often just a symbolic link to the gzip command, so using gzip -d achieves the same result.

Method #4: Extracting 7-Zip Archives

To install p7zip on Linux, you can use your distribution’s package manager. p7zip is a port of 7-Zip, and it provides the 7z command for handling 7-Zip archives. Here are instructions for some popular Linux distributions:

For Debian/Ubuntu-based Systems:

sudo apt-get update
sudo apt-get install p7zip-full

For Red Hat/Fedora-based Systems:

sudo yum install p7zip

For openSUSE-based Systems:

sudo zypper install p7zip

For Arch Linux:

sudo pacman -S p7zip

After installing p7zip, you can use the 7z command to work with 7-Zip archives. For example:

7z x file.7z

Replace file.7z with the actual 7-Zip archive you want to extract. The x option stands for “extract.”

Verify that the installation was successful by checking the version of 7z:

7z --version

Conclusion

Linux provides a variety of commands for extracting compressed files, offering flexibility and efficiency in file management. Whether dealing with tarballs, Zip files, Gzip, Bzip2, or 7-Zip archives, these commands make the extraction process seamless. Incorporate these commands into your Linux workflow to efficiently handle compressed files.

Hire us to handle what you want

Hire us through our Fiverr Profile and leave all the complicated & technical stuff to us. Here are some of the things we can do for you:

  • Website migration, troubleshooting, and maintenance.
  • Server & application deployment, scaling, troubleshooting, and maintenance
  • Deployment of Kubernetes, Docker, Cloudron, Ant Media, Apache, Nginx,  OpenVPN, cPanel, WHMCS, WordPress, and more
  • Everything you need on AWS, IBM Cloud, GCP, Azure, Oracle Cloud, Alibaba Cloud, Linode, Contabo, DigitalOcean, Ionos, Vultr, GoDaddy, HostGator, Namecheap, DreamHost, and more.
 

We will design, configure, deploy, or troubleshoot anything you want. Starting from $10, we will get your job done in the shortest time possible. Your payment is safe with Fiverr as we will only be paid once your project is completed.