Linux and Ubuntu users often deal with compressed files, which are used to save space and make file transfer more efficient. One common file compression format is the .tar.gz file. It is essential for users to be familiar with the process of extracting or “untarring” these files to access their contents.

Untar refers to the process of decompressing and extracting files from a tarball (tar archive) in Linux or Ubuntu. Tarballs are created to bundle multiple files and directories into a single file, which is then usually compressed using the gzip utility. By learning how to untar files, users will be able to conveniently access and manage files within the tarball, making their work with Linux or Ubuntu systems more seamless and efficient.

Understanding Tar Files and Compression

In Linux and other Unix-based systems, the tar command is widely used for compressing and decompressing files. Tar, short for Tape Archive, is a file format that allows multiple files and directories to be combined into a single archive file, usually with the extension .tar. These archives maintain the file structure and can be used for backup or file transfer purposes.

Although tar files are useful for bundling multiple files together, they do not provide compression on their own. However, they can be easily combined with compression algorithms like gzip or bzip2 to create compressed archives with extensions like .tar.gz or .tar.bz2. These compressed archives help save storage space and reduce the time spent on file transfers.

Here are some common tar command options:

  • -c : create a new archive
  • -x : extract files from an archive
  • -z : use gzip compression or decompression
  • -j : use bzip2 compression or decompression
  • -v : show verbose information during operation
  • -f : specify the archive file name

For example, to create a gzip compressed archive of a directory, you’d use the command: tar -czvf archive.tar.gz directory/. To extract the contents of a gzip compressed archive, you would use: tar -xzvf archive.tar.gz.

In summary, tar files are a convenient way to package multiple files and directories into a single archive, and when combined with compression algorithms like gzip or bzip2, they help save storage space and transfer time. Understanding the basic tar command options is essential when working with tar files in a Linux or Ubuntu environment.

Installing Tar Utility

Before you can extract or create tar files in Linux/Ubuntu, you need to ensure that the tar utility is installed on your system. By default, tar is pre-installed on most Linux/Ubuntu distributions. However, if for some reason it’s not installed or you’re using a minimal installation, you can easily install it with a few terminal commands.

For Ubuntu and Debian-based distributions, you can use the apt-get package manager to install the tar utility. Open the terminal and run the following command:

sudo apt-get update
sudo apt-get install tar

Similarly, for CentOS and RHEL-based distributions, you can use the yum package manager to install tar. Open the terminal and execute the following command:

sudo yum install tar

Once the installation is complete, you can check the version of the tar utility to ensure it’s installed correctly. You can do this by running the following command in the terminal:

tar --version

In the case you’re using another Linux distribution, refer to its official documentation or package manager to install the tar utility.

Untar a File using Terminal

To untar a file in Linux/Ubuntu using the terminal, you can use the tar command. The tar command is a widely used command-line utility for managing archived files in Linux systems. It provides multiple options to extract, list, and manipulate tar archived files.

For instance, to extract a .tar.gz file, use the following command:

tar -xvzf filename.tar.gz

In this command, the flags have specific functions:

  • x: Extract the files
  • v: Verbose mode, which lists all the files being extracted
  • z: Decompress the archive using gzip
  • f: Specify the filename of the archive

If you’re dealing with a .tar.bz2 file, replace the z flag with a j flag:

tar -xvjf filename.tar.bz2

Additionally, you can extract the files to a specific directory by adding the -C option followed by the target directory:

tar -xvzf filename.tar.gz -C target_directory

Remember always to replace filename.tar.gz and target_directory with your desired file and directory names.

Using the terminal to untar a file in Linux/Ubuntu presents a quick and efficient way to manage file extraction without the need for any third-party applications. Plus, with the appropriate flags and options, you can customize the extraction process to suit your specific requirements.

Untar a File Using GUI

In Linux/Ubuntu, you can also untar files using a Graphical User Interface (GUI) by utilizing file archive managers like File Roller or Ark. These applications provide an easy and convenient way to extract tar files without using command-line.

File Roller: File Roller, also known as Archive Manager, comes pre-installed in many Ubuntu distributions. To untar a file using File Roller, follow these steps:

  1. Right-click on the tar file you want to extract.
  2. Select “Open With Archive Manager” from the context menu.
  3. In the Archive Manager window, you can view the contents of the tar file.
  4. To extract the files, click the “Extract” button located at the top of the window.
  5. Choose the destination folder for the extracted files and click “Extract.”

Ark: Ark is another popular archive manager available for Linux/Ubuntu. To untar a file using Ark, follow these steps:

  1. Install Ark if it’s not already installed. You can use the following command for installation: sudo apt-get install ark
  2. Right-click on the tar file you want to extract.
  3. Select “Open With Ark” from the context menu.
  4. In the Ark window, you can view the contents of the tar file.
  5. To extract the files, click the “Extract” button located at the top of the window.
  6. Choose the destination folder for the extracted files and click “Extract.”

Both File Roller and Ark support various archive formats and provide a user-friendly interface for managing and extracting archive files in Linux/Ubuntu systems.


In this article, we have discussed the process of untarring a file in Linux/Ubuntu systems. We have covered essential commands and various options that can be used with these commands for effective file manipulation and management. Linux users can thus confidently handle tar archives and efficiently work with compressed files.

Understanding the tar and gzip commands, along with their options, enables users to extract and untar files with ease while maintaining file integrity. This knowledge is greatly valuable for system administrators and developers working in Linux environments.

Always remember to carefully read the man pages for tar and gzip to familiarize yourself with additional options and best practices. Continually updating your command-line skills will ensure that you’re prepared to efficiently handle file operations in Linux and Ubuntu systems.