What a tar.gz file is and why you need to extract it first
A tar.gz file is a compressed archive — think of it as a folder that has been squeezed down to save space. The ".tar" part means the files are bundled together, and the ".gz" part means they are compressed. Before you can use what is inside, you must extract (unpack) the archive to get back the original files and folders.
Linux does not automatically extract tar.gz files the way Windows extracts .zip files. You need to run a command in the terminal to unpack it. Once unpacked, you will have a folder containing the actual software or files you want to install or use.
The extraction step and the installation step are separate. Extracting just gets the files out of the archive. Installing usually means running a setup script or following the instructions that come with those files.
Key Takeaways
- Extract a tar.gz file by opening the terminal in the file's directory and running tar -xzf filename.tar.gz.
- After extraction, read the README or INSTALL file in the unpacked folder to learn what the software needs before it will run.
- Most Linux software installed from tar.gz files requires you to run ./configure, then make, then sudo make install in order.
- If you get a "permission denied" error, the file may not have execute permission — use chmod +x filename to fix it.
- Some tar.gz files contain pre-built binaries you can run directly without compiling, so always check the included documentation first.
Opening the terminal in the right location
The easiest way to extract a tar.gz file is to open a terminal window in the folder where the file sits. If you downloaded the file, it is probably in your Downloads folder. Open your file manager, navigate to that folder, then right-click in the empty space and select "Open Terminal Here" or "Open in Terminal" — the exact wording depends on your Linux desktop.
If that option does not appear, open a terminal window from your applications menu instead, then use the cd command to navigate to the folder. For example, if your file is in Downloads, type cd ~/Downloads and press Enter. The ~ symbol means your home directory.
Once you are in the correct folder, type ls and press Enter to list the files. You should see your tar.gz file in the list. If you do not, you are in the wrong folder — use cd again to navigate to the right place.
Extracting the tar.gz file with the correct command
To extract the archive, type this command exactly as shown and press Enter:
tar -xzf filename.tar.gz
Replace "filename" with the actual name of your file. For example, if your file is called software-1.0.tar.gz, you would type tar -xzf software-1.0.tar.gz. The command is case-sensitive, so match the uppercase and lowercase letters exactly as they appear in the filename.
The flags mean: -x extracts, -z handles the gzip compression, and -f tells tar to work with a file. You can also use tar -xzvf filename.tar.gz (adding a v) to see each file as it extracts — this is useful if you want to watch the progress.
The extraction usually takes a few seconds. When it finishes, the terminal prompt returns. Type ls again to see the new folder that was created. The folder name is usually the same as the archive name, but without the .tar.gz ending.
Reading the documentation before you install
After extraction, open the new folder by typing cd foldername (replace "foldername" with the actual name). Then type ls to see what is inside. Look for a file called README, INSTALL, or README.md — these files contain the instructions for that specific software.
Open the README file by typing cat README or less README (press q to exit the less viewer). Read it carefully. It will tell you what other software you need installed first, what the installation steps are, and whether this archive contains source code that needs compiling or a pre-built binary you can run directly.
This step saves time. Some software can be run immediately without installation. Some requires you to compile it from source code. Some is already compiled and just needs to be copied to the right location. The README tells you which one applies.
Installing from source code: the configure, make, install sequence
If the README says the software needs to be compiled, you will usually follow three steps in order. Make sure you are still inside the extracted folder (use pwd to check your current location), then run these commands one at a time, pressing Enter after each:
./configure — This checks your system to make sure you have everything the software needs. It may take a minute or two. If it fails, read the error message carefully — it usually tells you what is missing.
make — This compiles the source code into a working program. This step can take several minutes depending on the software size. Do not close the terminal or interrupt it.
sudo make install — This copies the compiled program to the system folders where it belongs. You need sudo (superuser do) because these folders are protected. You will be asked for your password. Type it and press Enter. The text will not show as you type, which is normal.
If any of these three steps fails, stop and read the error message. Copy the error text into a search engine along with the software name — someone else has usually hit the same problem and posted a solution.
Running pre-built binaries without compilation
Some tar.gz files contain software that is already compiled and ready to run. The README will say something like "binary distribution" or "pre-built". In this case, you do not need to run configure and make.
Instead, look for a file with the same name as the software (or a file called bin or run). To run it, type ./filename and press Enter. The ./ means "run this file from the current folder".
If you get a "permission denied" error, the file does not have execute permission. Fix it by typing chmod +x filename (replace "filename" with the actual name), then try running it again with ./filename.
Some pre-built software also includes an install script. Look for a file called install.sh or setup.sh. If it exists, the README will tell you to run it. Use ./install.sh or ./setup.sh to execute it.
Troubleshooting common extraction and installation problems
If you get "tar: command not found", tar is not installed on your system. This is rare on most Linux distributions, but if it happens, install it using your package manager. On Ubuntu or Debian, type sudo apt install tar. On Fedora or Red Hat, type sudo dnf install tar.
If the extraction command seems to do nothing and returns you to the prompt without creating a folder, check the filename again. Type ls *.tar.gz to list only tar.gz files and make sure you spelled the name correctly. Also check that the file is not corrupted — if it is very small (a few kilobytes), the download probably failed.
If configure fails saying "C compiler not found" or similar, you need to install development tools. On Ubuntu, type sudo apt install build-essential. On Fedora, type sudo dnf install gcc make. Then try configure again.
If make fails partway through, the most common cause is a missing library. Read the error message — it usually names what is missing. Search for "install [missing library name] [your Linux distribution]" to find the package you need.
Frequently Asked Questions
Can I extract a tar.gz file using the file manager instead of the terminal?
Yes. Right-click the tar.gz file in your file manager and look for "Extract" or "Extract Here". This works on most Linux desktops. However, using the terminal command gives you more control and lets you see if anything goes wrong during extraction.
What is the difference between tar -xzf and tar -xf?
The -z flag tells tar to decompress gzip compression automatically. If you use tar -xf on a .tar.gz file, it will fail because tar does not know to decompress it first. Always use -z for .tar.gz files. For plain .tar files without compression, -xf is correct.
Do I need to be root or use sudo to extract a tar.gz file?
No. Extracting only creates files in your current folder, which you own. You only need sudo when running make install to copy files to system directories. If you are asked for a password during extraction, something is wrong — stop and check your folder permissions.
What should I do if the software will not run after installation?
First, check that all three steps (configure, make, sudo make install) completed without errors. Then check the README for any additional setup needed. If the software still will not run, try running it from the terminal to see the error message — this usually tells you what is missing or misconfigured.
Can I delete the extracted folder after installation?
Usually yes, but check the README first. Some software keeps configuration files in the extracted folder. If the README does not mention keeping the folder, you can safely delete it after a successful installation. The installed software itself lives in system directories, not in the extracted folder.