How to install tar.gz file on Linux

The .tar.gz file format is a tar archive that has been compressed with gunzip compression. These archives are designed to be opened on Linux systems and can contain any type of files within them. Sometimes, software comes packaged in a .tar.gz file, and users can extract its contents in order to install what is inside.

Normally, software comes in the form of a compressed archive whenever it is to be compiled from source. Whereas distributable binaries are normally installed through other means, such as via the system’s package manager. In this tutorial, we will go over the step by step instructions to install software from a .tar.gz file on a Linux system.

In this tutorial you will learn:

  • How to extract content from a compressed tar file
  • How to install prerequisite packages to build from source
  • How to configure, make, and install source files
How to install tar.gz file on Linux
How to install tar.gz file on Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software tar, gzip, development tools
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Install prerequisites




To install software from a compressed archive, we will need the proper tools to extract the files and to compile the source code. We can use our system’s package manager to install these tools by executing the appropriate command below.

To install tar extraction and compiling tools on Ubuntu, Debian, and Linux Mint:

$ sudo apt update
$ sudo apt install tar gzip build-essential

To install tar extraction and compiling tools on Fedora, CentOS, AlmaLinux, and Red Hat:

$ sudo dnf groups mark install "Development Tools"
$ sudo dnf groupinstall "Development Tools"
$ sudo dnf install tar gzip

To install tar extraction and compiling tools on Arch Linux and Manjaro:

$ sudo pacman -Sy base-devel tar gzip

Install software from .tar.gz

WARNING
The recommended way to install software from source is to check the README file or official website for instructions. They may tell you to execute certain commands or include particular options, and may also reveal other prerequisite packages that are needed for installation in addition to the ones we showed you above.

With the disclaimer above out of the way, keep in mind that different packages may require a different set of instructions for installation. We will run through the most general steps that the majority of software packages follow for installation:

  1. Start by extracting the contents of your archive.
    $ tar xf software-name.tar.gz
    
  2. Change into the extracted directory, and see if there is a file that we can execute named configure. If so, execute it and follow the instructions on screen (if any).
    $ ./configure
    
  3. Next, use the make command to build and compile the software from the included source code files:
    $ make
    
  4. Then, to install the software on your system, run the following command. This part will require root permissions as we are installing software on the system.


    $ sudo make install
    

These are general instructions that most programs follow for installation. But please note that the developer may have special instructions that need to be followed in order for the program to function as expected. It is impossible for us to predict exactly how to install your specific .tar.gz file that you have downloaded, so use the instructions above only as a general guide.

Closing Thoughts

In this tutorial, we saw how to install software from a .tar.gz archive on a Linux system. Software source files are normally distributed this way, and require the user to build and compile the code before finally installing it on the system. Various software will require a unique set of instructions, but in general, most software installation will follow the steps shown above, and sometimes with slight differences that may or may not have an impact on the final result. Definitely make sure you consult the readme file or official instructions for the exact process.



Comments and Discussions
Linux Forum