You downloaded a program for Linux, but instead of a friendly installer you got a file ending in .tar.gz — and now you are not sure what to do with it. Learning how to install a tar.gz file in Ubuntu step by step is a rite of passage for Linux beginners, and it is simpler than it looks. A tar.gz file is just a compressed archive (like a ZIP file) that bundles software together. This guide walks you through extracting it, figuring out what kind of software it contains, and installing it correctly — with every command explained.
In This Guide
- What Is a Tar.gz File, Exactly?
- Before You Start: What You Need
- Step 1: Inspect the Archive Before Extracting
- Step 2: Extract the Tar.gz File
- Step 3: Identify What Kind of Software It Is
- Step 4: Install From Source (Configure, Make, Install)
- Step 5: Install Pre-compiled Binaries
- Step 6: Verify the Installation
- Easier Alternatives Worth Knowing
- Troubleshooting Common Errors
- Frequently Asked Questions
- Key Takeaways
What Is a Tar.gz File, Exactly?
The name tells you everything. tar (tape archive) bundles many files into one, and gz (gzip) compresses that bundle to save space. Windows users can think of it as the Linux world’s ZIP file. Developers distribute software as tar.gz archives because the format preserves Linux file permissions and works on every Unix-like system.
Inside a tar.gz you will typically find one of three things:
- Source code you need to compile yourself (it will contain files like
configure,Makefile, orCMakeLists.txt). - Pre-compiled binaries that run immediately after extraction (common with tools like VS Code alternatives, game servers, or developer tools).
- An installer script that does everything for you when executed.
Which type you have determines the installation steps — that is why Step 3 below matters. Most of the commands you will use here are covered in our Ubuntu terminal commands cheat sheet for beginners if you want a quick reference to keep open in another tab.
Before You Start: What You Need
Open a terminal (Ctrl + Alt + T) and make sure you have the basic build tools. If the archive contains source code, you will need a compiler and the make utility. Install them with one command:
sudo apt update
sudo apt install build-essential
build-essential is a meta-package that pulls in GCC, G++, make, and the standard C/C++ headers — everything most source builds require. You will also want curl or wget if you downloaded the file via the browser (already installed on most Ubuntu systems).
One more tip for beginners: you do not need to be root to extract an archive. Only the final installation step (copying files into system directories like /usr/local) needs sudo. If you are setting up a fresh machine, you may first need to create a new user in the Ubuntu terminal with sudo privileges.
Step 1: Inspect the Archive Before Extracting
Never extract a mystery archive blindly. First, look at what is inside without unpacking it:
tar -tzf ~/Downloads/program-1.2.3.tar.gz | head -30
The flags mean: t = list contents, z = gzip compression, f = the file follows. The head -30 shows just the first 30 entries so a huge archive does not flood your screen.
Check two things in the output. First, do all paths start with a single folder name like program-1.2.3/? If yes, extracting is safe — everything lands in one folder. If files would scatter into your current directory (no common top-level folder), extract into a dedicated directory instead, which we cover in the next step.
Step 2: Extract the Tar.gz File
Navigate to where you want the files (your Downloads folder is fine) and extract:
cd ~/Downloads
tar -xzf program-1.2.3.tar.gz
Here x means extract. After this runs, you will have a new directory — usually named after the program and version. To extract into a specific directory instead (useful when the archive has no top-level folder):
mkdir -p ~/apps/program
tar -xzf program-1.2.3.tar.gz -C ~/apps/program
The -C flag tells tar to change into that directory before extracting. Now move into the extracted folder and look around:
cd program-1.2.3
ls -la
The listing tells you what you are dealing with. A README, INSTALL, or README.md file is your best friend — always read it first, because the project’s own instructions override any generic guide.
Step 3: Identify What Kind of Software It Is
Run this quick diagnosis inside the extracted folder:
ls
file * 2>/dev/null | head -20
- If you see
configureorMakefile: it is source code — follow Step 4. - If you see
CMakeLists.txt: it is source code using CMake — the README will give the exact build commands (usuallymkdir build && cd build && cmake .. && make). - If you see an executable binary (run
file programnameand it says “ELF 64-bit LSB executable”) plus libraries: it is a pre-compiled binary — follow Step 5. - If you see
install.shor similar: it is a self-installing package. Read it first (less install.sh), then run it — usually./install.shorsudo ./install.sh.
Step 4: Install From Source (Configure, Make, Install)
Compiling from source sounds intimidating, but it is almost always the same three commands. Here is the classic sequence and what each step does:
./configure
The configure script inspects your system — checking for compilers, libraries, and dependencies — and generates a Makefile customized for your machine. Watch its output: if it complains about a missing library (for example, configure: error: ... not found), install that library with sudo apt install and run configure again. The Ubuntu package you need is usually the library name plus -dev, like libssl-dev.
make -j$(nproc)
This compiles the source code into binaries. The -j$(nproc) flag tells make to use all your CPU cores, which can cut compile time dramatically on multi-core machines. Grab a coffee for large projects — this is the step that takes time.
sudo make install
This copies the compiled binaries, libraries, and documentation into system directories (typically under /usr/local). The sudo is needed because those directories are write-protected.
Some projects let you choose a custom install location so you do not need sudo at all:
./configure --prefix=$HOME/.local
make -j$(nproc)
make install
This installs everything under your home directory. Add $HOME/.local/bin to your PATH and the program runs just for your user — a clean approach that keeps system directories untouched.
Step 5: Install Pre-compiled Binaries
If the archive contains ready-to-run binaries, installation is much simpler. First, test that the binary works:
./programname --version
If it prints a version, you are in business. To make it available everywhere (instead of only when you cd into that folder), you have two good options.
Option A: move it to a directory already on your PATH. /usr/local/bin is the conventional home for manually installed programs:
sudo cp programname /usr/local/bin/
programname --version
Option B: symlink it. This keeps the program’s folder intact (useful when it needs its bundled libraries sitting next to the binary):
sudo ln -s ~/apps/program/programname /usr/local/bin/programname
If the binary refuses to run with a “permission denied” error, it probably lost its executable bit during download. Fix it with:
chmod +x programname
Some binary distributions also ship a .desktop file. Copy it to ~/.local/share/applications/ and the program appears in your applications menu with its icon.
Step 6: Verify the Installation
Confirm the program installed correctly and is reachable:
which programname
programname --version
which shows the full path of the executable your shell will run. If which returns nothing, the binary is not on your PATH — revisit Step 5. Also check that the program’s man page or help output works:
programname --help | head -20
Easier Alternatives Worth Knowing
Tar.gz installation is a useful skill, but it is rarely the easiest route. Before compiling from source, check whether the software is available through Ubuntu’s normal channels:
- APT repository:
sudo apt install programname— gets you automatic updates and clean uninstalls. Always check this first. - Snap:
sudo snap install programname— sandboxed, auto-updating packages maintained by Canonical and vendors. - .deb package: if the vendor offers one, install it with
sudo apt install ./package.deb— APT resolves dependencies for you.
Use the tar.gz route when the software is not packaged for Ubuntu, when you need a newer version than the repositories carry, or when you want to compile with custom options. The official Ubuntu tutorials cover package management in more depth if you want to compare approaches.
Troubleshooting Common Errors
“tar: command not found”
Extremely rare on Ubuntu, but fixable instantly: sudo apt install tar.
“configure: error: C compiler cannot create executables”
You skipped the prerequisites. Run sudo apt install build-essential and try again.
“fatal error: someheader.h: No such file or directory” during make
A development library is missing. Search for which package provides it (apt-file helps, or just search the web for the header name plus “ubuntu”), install the -dev package, and re-run make.
“permission denied” when running ./configure
The script is not executable: chmod +x configure, then run it again.
The program installs but the command is “not found”
Your shell has not picked up the new binary. Either open a new terminal or run hash -r to clear the command cache, then try again.
Frequently Asked Questions
Is it safe to install software from a tar.gz file?
As safe as the source you downloaded it from. Unlike APT packages, tar.gz archives are not signature-verified automatically, so only download them from the project’s official website or GitHub releases page. When available, verify the published SHA256 checksum against your download with sha256sum file.tar.gz.
How do I uninstall software I installed from a tar.gz?
If you compiled from source, many projects support sudo make uninstall run from the same build directory — keep the extracted folder until you are sure. For manually copied binaries, simply delete the files you added (the binary in /usr/local/bin, and the extracted folder). This lack of clean uninstall is one reason package managers are preferable when available.
What is the difference between .tar.gz and .tgz?
Nothing functional — .tgz is just a shorter spelling of .tar.gz. The exact same tar -xzf command handles both.
Can I install a tar.gz file with a graphical tool?
Yes. Ubuntu’s Archive Manager (File Roller) opens tar.gz files with a double-click, and you can extract via right-click. But the terminal route is faster, scriptable, and what every tutorial assumes — worth learning.
Do I need to keep the extracted folder after installing?
For source builds, keep it until you have verified the install works (you need it for make uninstall). For pre-compiled binaries that you copied elsewhere, the extracted folder can be deleted once the program runs from its installed location.
Key Takeaways
- A tar.gz is a compressed archive — always list its contents with
tar -tzfbefore extracting. - Extract with
tar -xzf file.tar.gz(add-C directoryto control where files land). - Read the README/INSTALL file first — project instructions beat generic guides.
- Source code installs follow the classic trio:
./configure,make -j$(nproc),sudo make install(after installingbuild-essential). - Pre-compiled binaries just need to be copied or symlinked into
/usr/local/bin. - Check APT, Snap, or a .deb package first — tar.gz is the fallback, not the default.
Conclusion
Knowing how to install a tar.gz file in Ubuntu step by step removes one of the biggest beginner fears in Linux. The workflow is always the same: inspect the archive, extract it, identify whether you have source code or binaries, then follow the matching path — configure/make/install for source, copy-to-PATH for binaries. Keep build-essential installed, read the README before you type anything, and prefer your package manager when it has what you need. Do that, and no tar.gz file will ever slow you down again.