How to Install .tgz Files in Linux

In this article, we’re discussing how to install an application contained in a .tgz file. Before we begin, note you are not installing the actual .tgz file, itself, rather you are compiling the source code of the application contained within the .tgz file through a series of commands.

We are using Zorin OS 16, an Ubuntu-based distro, for this guide. All of the Linux commands featured in this article are distro-independent, meaning they will work on any Linux distro.

What Is a .tgz File?

Think of a .tgz file as .zip file for Linux. .tgz files are compressed Linux files compressed using the tar command on the command line. The tar command can also be used to uncompress .tgz files. In the Linux GUI,  the Archive Manager utility is used for compression and uncompression. Note that other compressed files Linux files can have several different file extensions, including:
  • .tar
  • .tar.gz
  • .bz
  • .gz
  • .bz2
  • .tar.bz2
  • .tbz2
  • .tar.gz
  • .bz2

Most of the file types listed can also be also by uncompressed via the tar command or the Archive Manager. The Archive Manager is a preinstalled GUI utility available on Linux distros utilizing the GNOME desktop environment.

There are two ways to open a .tgz file, either from the command line or using the Archive Manager. However, you shouldn’t use the Archive Manager to open a .tgz file, as you need the command line to run a number of script files contained within the .tgz files to actually install the application.

How to open and install a .tgz File

    1. Download the required .tgz file to your system. Launch the terminal and navigate to the location of your .tgz file.
    2. Extract the .tgz file using the tar command.
      # tar -xzfv application_name.tgz

      Note the options ( -xzfv) we used with the tar command.

        • The -x option – extract the .archive file.
        • The -z option – filter the archive through gzip.
        • The -f option – the filename of the archive file.
        • The -v option – show the progress of the extraction.
    3. Next, navigate to the newly-created directory where the .tgz file was extracted to.
      # cd application_directory_name

       

    4. Then run the configure command to configure the source code so that it can be compiled on your system. You may be asked some questions about how you want to build the application during this process, also.
      # ./configure

       

    5. Now, invoke the make command to compile the source code. Note that this process could be lengthy if compiling a large application.
      # make

       

    6. Finally, run the make install command to copy the code you compiled into the Linux OS so that it can be executed.
      # make install

Example Installation – wmx-8

In our example, we’ll be installing wmx-8, a window manager for X.

    1. Download the wmx-8.tar.gz file to the /tmp directory.
    2. Extract wmx-8.tar.gz.
      # tar -xzfv wmx-8.tar.gz
    3. Change directory to /tmp/wmx-8.
      # cd /tmp/wmx-8
    4. Configure the source code to make it ready to compile.
      # ./configure
    5. Compile the source code.
      # make
Configure the source code to make it ready to compile.
Configure the source code to make it ready to compile.
Run the make command to compile the source code and install.
Run the make command to compile the source code and install it.

Normally, we would run make install after this, but it’s not necessary in this case as the make command did it for us.

Linux Commands Used In this Article

  • sudo – allows a permitted user to execute a command as the superuser or another user, as specified by the security policy.
  • cd –  change the working directory.
  • tar – an archiving utility for Linux.
  • ls – list directory contents.
  • make – a utility that will determine automatically which pieces of a large program need to be recompiled, and issue the commands to recompile them.

Was this article helpful?

Leave a Comment