What a tar.gz file is and why you extract instead of install it
A tar.gz file is a compressed archive — think of it as a folder that has been squeezed down and wrapped up. The ".tar" part means the files are bundled together, and the ".gz" part means they are compressed. When you download a tar.gz file, you are not downloading a ready-to-run program. You are downloading the source code or pre-built files that you then extract to a folder on your computer.
The word "install" can be misleading here. Most of the time, extracting a tar.gz file is the entire process. You pull the files out, and they are ready to use. Sometimes the archive contains a setup script that you run after extraction, but there is no installer window or registry entry like you might see on Windows. Linux does not work that way.
You will encounter tar.gz files when downloading software directly from a project's website, when a package manager is not available for your system, or when you need a specific version that is not in your distribution's repository. Understanding how to extract and use these files gives you access to software that might not be packaged for your Linux distribution.
Key Takeaways
- Extract a tar.gz file using tar -xzf filename.tar.gz in the terminal, which creates a folder with the contents.
- Read the README or INSTALL file inside the extracted folder first — it tells you what to do next, which varies by project.
- Some archives need you to run a configure script and then make, while others are already compiled and ready to use immediately.
- Use sudo make install only if the README tells you to, and only after you understand what it does on your system.
Extracting the tar.gz file with the tar command
Open a terminal 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. 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 which file to work with. The order of the flags does not matter. After you press Enter, the tar command will create a new folder (usually named after the project) and place all the extracted files inside it.
If you want to extract the files to a specific folder instead of the current directory, add -C /path/to/folder at the end. For example, tar -xzf filename.tar.gz -C ~/myapps extracts everything into the myapps folder in your home directory. If the folder does not exist, create it first with mkdir ~/myapps.
Finding and reading the installation instructions
After extraction, navigate into the new folder that was created. Type cd foldername, then list the contents with ls. Look for files named README, INSTALL, CONTRIBUTING, or similar. These files contain the actual instructions for that specific project, and they are your most reliable guide.
Read the README file by typing cat README or less README. The less command lets you scroll through longer files with the arrow keys and space bar; press q to exit. The README will tell you whether the software is already compiled and ready to use, or whether you need to run a configuration and build process first.
Different projects have different requirements. Some archives contain pre-compiled binaries that you can run immediately. Others contain source code that must be compiled on your system. The README is where the maintainers explain which one you have and what to do next. Skipping this step is the most common reason people get stuck.
Running configure and make for source code
If the README says you need to compile the software, you will typically see three commands listed. First, run the configure script:
./configure
This script checks your system for dependencies and sets up the build. It may take a minute or two. If it fails, it will tell you which libraries or tools are missing. Install those using your package manager (apt, dnf, pacman, or whatever your distribution uses), then run configure again.
After configure finishes successfully, run:
make
This compiles the source code into executable programs. It can take several minutes depending on the size of the project. You will see a lot of text scroll past — that is normal. If it stops with an error, read the error message carefully. Often it means a dependency is missing or your system does not have a required tool.
Once make finishes, the compiled files are ready in the folder. If you only need to run the program from this folder, you are done. If you want to install it system-wide so you can run it from anywhere, the README will tell you whether to run sudo make install. Only run this command if the README explicitly says to do so.
When to use sudo make install and what it does
The sudo make install command copies the compiled program and its files to system directories like /usr/local/bin, /usr/local/lib, or /opt. This makes the program available to all users on the system and adds it to your PATH so you can run it from any folder by typing its name.
Only run sudo make install if the README or INSTALL file tells you to. Running it without understanding what it does can place files in unexpected locations or overwrite existing programs. If you are unsure, you can run the program directly from the extracted folder instead. For example, if the program is called myapp, type ./myapp to run it from the current directory.
If you do run sudo make install and later want to remove the program, look for an uninstall target. Type make uninstall (with sudo if needed) from the same folder where you ran make install. Not all projects provide this, so check the README first.
Running pre-compiled binaries directly
Some tar.gz archives contain pre-compiled programs that are ready to run immediately after extraction. The README will say something like "no compilation needed" or "ready to use." In this case, you can run the program directly without configure or make.
Navigate into the extracted folder and look for an executable file — often named after the project or simply called "bin" or "app." Type ./filename to run it. The ./ tells the system to run the program in the current folder.
If you want to run this program from anywhere on your system without typing the full path, you can add the folder to your PATH or copy the executable to a folder that is already in your PATH, like /usr/local/bin. The README usually explains the recommended way to do this for that specific project.
Troubleshooting common extraction and build problems
If the tar command says "cannot open" or "no such file," check the filename. Type ls *.tar.gz to list all tar.gz files in the current folder and make sure you spelled it correctly. File names are case-sensitive in Linux.
If configure fails, it will list missing dependencies. Install them using your package manager. For Ubuntu and Debian, use sudo apt update and sudo apt install packagename. For Fedora, use sudo dnf install packagename. For Arch, use sudo pacman -S packagename. After installing dependencies, run configure again.
If make fails partway through, the error message usually points to the problem. Common issues include missing build tools (install "build-essential" on Debian-based systems or "base-devel" on Arch), incompatible library versions, or code that does not compile on your specific system version. Copy the error message into a search engine along with the project name — someone has usually encountered the same problem and posted a solution.
Frequently Asked Questions
Do I need to extract tar.gz files to a specific folder?
No. You can extract them anywhere you have write permission — your home folder, Desktop, Downloads, or a dedicated folder like ~/src or ~/apps. The README will sometimes recommend a location, but most projects work fine from any folder. Just remember where you extracted it so you can find it later.
What is the difference between tar.gz and tar.bz2?
Both are compressed archives. The .gz uses gzip compression, and .bz2 uses bzip2 compression. To extract .tar.bz2, use tar -xjf filename.tar.bz2 — the only difference is the -j flag instead of -z. The process after extraction is identical.
Can I delete the tar.gz file after extracting it?
Yes. Once you have extracted the contents, the tar.gz file is no longer needed unless you want to keep a backup or extract it again on another system. Deleting it frees up disk space.
How do I know if a program was installed correctly with make install?
Type the program name from any folder — for example, myapp --version. If it runs, it was installed correctly. If you get "command not found," it either was not installed or the installation folder is not in your PATH. Check the README for the correct installation path.
What if I want to uninstall a program I compiled from source?
If you ran make install, try sudo make uninstall from the same extracted folder. If that does not work, the project may not have provided an uninstall target. In that case, you will need to manually delete the files, which is tedious. This is one reason many people prefer using their distribution's package manager when possible.