What a tar.gz file is and why you extract it instead of installing it
A tar.gz file is a compressed folder. It bundles source code or pre-built programs into one file, then squeezes it down with compression. When you read a tar.gz, you are not running an installer — you are unpacking a box. Linux does not have a single "install" button for these files the way Windows has .exe files. Instead, you extract the contents, check what is inside, and then either run the program directly or compile it from source code.
The reason you will encounter tar.gz files is that many open-source projects and development tools distribute themselves this way. Package managers (like apt or yum) handle the downloading and extracting for you, but when you need a specific version, or when a tool is not in your package manager's repository, you read the tar.gz yourself and extract it by hand.
The process has three parts: extract the file, navigate to the folder it creates, and then either run the program or build it. Which one you do depends on what is inside — and the README file in that folder will tell you.
Key Takeaways
- Extract a tar.gz file using the command tar -xzf filename.tar.gz, which creates a folder with the contents.
- The extracted folder usually contains a README file that explains whether you need to compile the program or if it is ready to run.
- If compilation is needed, you typically run ./configure, then make, then sudo make install in that order.
- Pre-built binaries (ready-to-run programs) can often be moved to /usr/local/bin so you can run them from anywhere on your system.
- Always read the README or INSTALL file first — it tells you exactly what your system needs and what commands to run.
Extract the tar.gz file using the tar command
Open a terminal and navigate to the folder where your tar.gz file is located. If it is in your Downloads folder, type cd ~/Downloads. Then run this command:
tar -xzf filename.tar.gz
Replace filename with the actual name of your file. The flags mean: -x extracts, -z handles the gzip compression, and -f tells tar to read from a file. You do not need to memorize this — it is the standard command for every tar.gz file you will encounter.
After you run it, a new folder will appear in the same directory. List the contents with ls to see it. The folder name usually matches the tar.gz filename but without the .tar.gz extension. Move into that folder with cd foldername.
Check the README or INSTALL file to understand what comes next
Inside the extracted folder, look for a file named README, README.md, INSTALL, or INSTALL.txt. Open it with a text editor like nano or cat:
cat README
This file is your instruction manual. It will tell you whether the program is pre-compiled (ready to run when ready) or whether you need to build it from source code. It will also list any dependencies — other programs or libraries your system needs before this one will work.
If the README says "pre-built binary" or "ready to use", the program is already compiled and you can skip the build step. If it says "compile from source" or mentions running ./configure, you will need to build it. Read this file completely before running any commands — it often contains version requirements or special flags you need to know about.
Build from source code if the program is not pre-compiled
If the README tells you to compile, the folder contains source code that must be turned into a runnable program. This process is the same for most open-source projects. Navigate to the extracted folder and run these three commands in order:
./configure
This command checks your system for everything the program needs. It will tell you if something is missing. If it fails, read the error message — it usually names the missing dependency. Install it with your package manager (apt install, yum install, etc.) and run ./configure again.
Once ./configure completes without errors, run:
make
This compiles the source code into a runnable program. It can take anywhere from a few seconds to several minutes depending on the program size. You will see a lot of text scroll past — that is normal. If it stops with an error, the error message usually points to what went wrong.
When make finishes, run:
sudo make install
This copies the compiled program to system directories so you can run it from anywhere. sudo is needed because you are writing to protected folders. You may be asked for your password.
Move a pre-built binary to a system folder so you can run it anywhere
If the extracted folder contains a pre-built binary (a file that is already compiled and ready to run), you can run it when ready from inside the folder. But to run it from any directory, move it to a system folder that is in your PATH.
First, find the binary. It is usually in a folder called bin inside the extracted directory. Look for a file without a file extension that has an executable icon or is listed as "executable" when you run ls -l. Once you find it, move it to /usr/local/bin:
sudo mv ./bin/programname /usr/local/bin/
Replace programname with the actual name of the binary. After this, you can type the program name from any terminal window and it will run. If you want to remove it later, use sudo rm /usr/local/bin/programname.
Verify the installation by running the program
After installation (whether compiled or moved), test that the program works. Most command-line programs respond to the --version or --help flag:
programname --version
If you see version information or a help menu, the installation succeeded. If you get "command not found", the program is not in your PATH. Check that you moved it to /usr/local/bin or that make install completed without errors.
If the program is graphical (not command-line), look for it in your applications menu or run it by name from the terminal. Some programs take a moment to launch the first time.
Uninstall or remove the program if needed
If you compiled from source and ran sudo make install, uninstalling is not always straightforward because different projects use different installation paths. Check the README for an uninstall command, or try sudo make uninstall from the extracted folder.
If you moved a pre-built binary to /usr/local/bin, remove it with:
sudo rm /usr/local/bin/programname
You can also delete the extracted folder once the program is installed — it is no longer needed. Use rm -r foldername to remove it.
Frequently Asked Questions
What if tar -xzf does not work?
Make sure you are in the correct directory and that the filename is spelled exactly right (including capitalization). If the file is corrupted, try downloading it again. On very old Linux systems, you might need to use tar -xzf with a space before the filename, or use gunzip and tar as separate commands.
Can I install a tar.gz file without using the terminal?
Most graphical file managers can extract tar.gz files by right-clicking and selecting "Extract" or "Extract Here". However, the build step (./configure, make, sudo make install) requires the terminal. You cannot avoid it if the program needs to be compiled.
What does "permission denied" mean when I try to run the program?
The file exists but is not marked as executable. Run chmod +x programname to make it runnable, then try again. If you moved it to /usr/local/bin, use sudo chmod +x /usr/local/bin/programname.
Do I need to keep the extracted folder after installation?
No. Once sudo make install completes or you move the binary to /usr/local/bin, the extracted folder can be deleted. The program is now installed on your system. Keep the original tar.gz file if you think you might need to reinstall it later.
Why does ./configure fail with missing dependencies?
The program needs libraries or tools your system does not have. The error message names what is missing. Search for that package in your package manager (apt search, yum search) and install it, then run ./configure again. You may need to install several dependencies before it succeeds.