What a tar.gz file is and why you extract instead of install it
A tar.gz file is a compressed folder containing source code or pre-built programs. Unlike .deb packages that Ubuntu's package manager handles automatically, a tar.gz file requires you to extract it first, then either compile the code or run the program directly from the extracted folder.
Most tar.gz files contain source code that you compile yourself using a compiler like GCC. Some contain pre-built binaries that run immediately after extraction. The file extension tells you nothing about which one you have — you need to look inside after extracting.
Ubuntu does not "install" tar.gz files the way it installs .deb packages. Instead, you extract the archive, check what's inside, and either compile it or copy the executable to a system folder so you can run it from anywhere.
Key Takeaways
- Extract a tar.gz file using tar -xzf filename.tar.gz in the terminal, which creates a new folder with the contents.
- Check the extracted folder for a README or INSTALL file that explains whether you need to compile the code or if binaries are ready to use.
- For source code, run ./configure, then make, then sudo make install to compile and place the program in system folders.
- For pre-built binaries, copy the executable file to /usr/local/bin so you can run it from any terminal window without typing the full path.
- If extraction or compilation fails, check that you have build-essential installed and that the tar.gz file matches your Ubuntu version and processor type.
Extract the tar.gz file using the terminal
Open a terminal window and navigate to the folder where your tar.gz file is located. If the file is on your Desktop, type cd ~/Desktop. If it is in your Downloads folder, type cd ~/Downloads.
Run this command to extract the file:
tar -xzf filename.tar.gz
Replace filename with the actual name of your file. The command creates a new folder in the same location with the extracted contents. You can now see what is inside by typing ls to list the folder contents, or by opening the extracted folder in your file manager.
Check what type of installation the tar.gz contains
Navigate into the extracted folder by typing cd foldername, where foldername is the name of the folder that was created. List the contents with ls to see what files are present.
Look for a file named README, INSTALL, or CONTRIBUTING. Open one of these with a text editor by typing cat README or nano INSTALL. These files explain whether the folder contains source code that needs compiling or pre-built binaries ready to run.
If you see a file named configure or Makefile, the contents are source code. If you see executable files (often marked with an asterisk when you type ls, or showing as "executable" in the file manager), you have pre-built binaries.
Compile source code using configure, make, and make install
If the folder contains a configure script, you are working with source code. First, make sure you have the build tools installed. Type:
sudo apt install build-essential
Then run the three-step compilation process. In the extracted folder, type:
./configure
This script checks your system for required libraries and prepares the code for compilation. It may take a minute or two. If it fails, read the error message — it usually tells you which library is missing. Install the missing library with sudo apt install libraryname and run ./configure again.
Once ./configure completes successfully, type:
make
This compiles the source code into a working program. It can take several minutes depending on the size of the project. Do not close the terminal window while it runs.
When make finishes, type:
sudo make install
This copies the compiled program to system folders so you can run it from any terminal window. You will be prompted for your password.
Install pre-built binaries by copying them to a system folder
If the extracted folder contains executable files but no configure script, you have pre-built binaries. You can run them directly from the extracted folder by typing ./programname, but to run them from anywhere, copy the executable to a system folder.
First, identify which file is the main executable. It is usually the largest file or the one with the same name as the program. You can test it by typing ./filename in the extracted folder. If a window opens or output appears in the terminal, you have found the right file.
Copy the executable to /usr/local/bin so it runs from anywhere:
sudo cp filename /usr/local/bin/
Replace filename with the actual executable name. You can now type the program name in any terminal window to run it, without navigating to the extracted folder first.
Verify the installation worked
After compilation or copying, test that the program runs. Type the program name in a terminal window. If it launches or shows version information, the installation succeeded.
If you get a "command not found" error after copying a binary, the file may not be marked as executable. Fix this by typing:
sudo chmod +x /usr/local/bin/filename
Then try running the program again. If compilation failed, re-read the error message from the ./configure or make step — it usually specifies which library or tool is missing.
Uninstall or remove a tar.gz installation
If you compiled from source using make install, some programs include an uninstall option. Navigate back to the extracted folder and type:
sudo make uninstall
If that command does not exist or does not work, you can manually remove the program. Most make install commands place files in /usr/local/bin, /usr/local/lib, or /usr/local/share. You can remove them by typing:
sudo rm /usr/local/bin/programname
For binaries you copied manually, simply delete the file from /usr/local/bin. You can also delete the extracted folder once installation is complete — it is no longer needed.
Frequently Asked Questions
What does the tar command actually do?
The tar command unpacks a compressed archive. The flags -xzf mean: extract (x) a gzip-compressed file (z) and read the filename from the command (f). It is equivalent to right-clicking a .zip file and selecting "Extract All" in a graphical file manager.
Do I need to keep the extracted folder after installation?
No. Once you have run make install or copied the binary to /usr/local/bin, the extracted folder can be deleted. The program is now installed in system locations. You only need the extracted folder if you want to run make uninstall later.
Why does my tar.gz file not extract?
The file may be corrupted or incomplete. Try downloading it again. If extraction still fails, check that the filename actually ends in .tar.gz — some files are named .tar.gz but are actually a different format. You can also try tar -tzf filename.tar.gz to list the contents without extracting; if that fails, the file is damaged.
What if configure or make returns an error about missing dependencies?
Read the error message carefully — it usually names the missing library or tool. Search for the library name in Ubuntu's package repository using apt search libraryname, then install it with sudo apt install libraryname. Run ./configure again after installing each missing dependency.
Can I install a tar.gz file meant for a different Linux distribution?
Sometimes, but not always. If the tar.gz contains source code, it may compile on Ubuntu even if it was built for another distribution. If it contains pre-built binaries, they usually only work on the distribution they were built for. Check the README file or the project website to confirm the file matches your Ubuntu version and processor type (64-bit or 32-bit).