How to Extract a File in Linux

Several compressed files are included in a TAR.GZ file to reduce download bandwidth and storage space.

Sometimes referred to as a tarball, the .TAR file serves as a portable container for other files.

The extension’s .GZ suffix refers to GZIP, a widely used compression tool.

GZIP extracts the file into the current directory by default.

To verify that the file has been compressed after zipping it, type the command ls.

The GUNZIP command can be used to decompress a file:

Enter the following to compress every .txt file in a specific directory:

tar -czvf directory.tar.gz *.txt

A TAR file combined with a GZ file is called a TAR.GZ file.

These files can be unzipped in the same manner as a standard zipped file:

tar -xzvf file.tar.gz

TAR is the standard command, and it has four options:

  • -c creates a new archive
  • -x extracts files from an archive
  • -z filters the archive through gzip
  • -v displays verbose output

Enter the following to view a .TAR file’s contents before you extract it:

tar -tvf file.tar

To give TAR instructions about where to store the extracted, unzipped files, enter:

tar -xvf file.tar -C /path/to/directory

The command to create a TAR.GZ file is as follows:

tar -czvf archive.tar.gz file1 file2 file3

Use the following command to append several files to a tar file:

tar -rvf archive.tar file1 file2 file3

In order to retrieve the files from a tar file, type:

tar -xvf archive.tar

Additionally, you can use xargs and tar to create a tar.gz archive and add files from the find command to it.

A command-line tool for managing tar.gz files is included in some graphical user interfaces.

Let’s explore Linux command line file extraction.

Use the unzip command and the ZIP file name to extract the files from a ZIP file. It should be noted that the .zip extension is required.


The files are listed in the terminal window as they are extracted.

ZIP files don’t store file ownership information. The owner of every file that is extracted is the user that is extracting it.

Similar to zip, unzip offers a -q (quiet) option that allows you to extract files without seeing the file listing.

unzip -q

Use the -d (directory) option and supply the path to the directory you want the archive to be extracted into if you want the files to be extracted in a particular directory.

unzip -d ./development -q

We will then learn how to extract a file.

Type FILE EXPLORER into the taskbar search box, then choose it from the list of results.

To zip a file, right-click on it and choose SEND TO > COMPRESSED (ZIPPED) FOLDER.

Use the right-click menu to choose EXTRACT ALL, then follow the prompts to unzip the entire folder.

Alternatively, you can use the command ribbon to select EXTRACT ALL.

Double-clicking the compressed folder will open it and allow you to decompress a single file or folder. Next, move the item to a new location by dragging or copying it from the compressed folder.

Let’s look at how to unzip a file in a Unix system.

Often found on Unix systems, unzip can list, test, or extract files from a ZIP archive.

When no options are selected, the default behavior extracts all of the files from the specified ZIP archive into the current directory and any subdirectories below it.


Take [] out.


Assume we have three text files with names of a.txt, b.txt, and c.txt inside of a zip file called "" We must extract the zip file to the current directory.



Here, we show every file that has been unzipped from the compressed file using the ls command.

[Extract a file]

File unzipping