What a tar.xz file is and why you need to extract it first
A tar.xz file is a compressed archive — think of it as a folder that has been squeezed down to take up less space. The ".tar" part means multiple files and folders are bundled together, and the ".xz" part means that bundle has been compressed. You cannot run or install anything directly from a tar.xz file. You must extract it first, which unpacks all the files inside it back to their original size and structure.
Linux systems do not automatically know how to handle tar.xz files the way Windows handles .zip files. You need to use a command-line tool to extract the archive, then follow whatever installation instructions came with the software inside. The process takes a few minutes and involves typing commands in the terminal.
Key Takeaways
- Extract a tar.xz file by opening a terminal in the folder where the file is located and typing tar -xf filename.tar.xz.
- After extraction, read the README or INSTALL file that appears in the extracted folder to learn what to do next — different software has different installation steps.
- Some software requires you to compile the code using ./configure, make, and make install commands in sequence.
- Other software is already compiled and just needs to be moved to the right folder or run directly from where you extracted it.
- You can delete the original tar.xz file after extraction if you want to save space, but keep the extracted folder until you confirm the software works.
Opening a terminal in the correct folder
The easiest way to extract a tar.xz file is to work in the folder where it is already located. Open your file manager and navigate to the folder containing the tar.xz file. Right-click in the empty space of that folder and look for an option that says "Open Terminal Here" or "Open in Terminal". If you do not see that option, open a terminal window separately and use the cd command to navigate to the folder.
For example, if your tar.xz file is in your Downloads folder, you would type cd ~/Downloads and press Enter. You can verify you are in the right place by typing ls and pressing Enter — this will list all files in the current folder, and you should see your tar.xz file in that list.
Extracting the tar.xz file with the tar command
Once you are in the terminal and in the correct folder, type this command exactly as shown, replacing "filename" with the actual name of your file:
tar -xf filename.tar.xz
Press Enter and wait. The extraction process may take anywhere from a few seconds to a few minutes depending on the file size. You will not see a progress bar — the terminal will simply return to the command prompt when it is done. Type ls again to see the extracted folder, which will usually have the same name as the tar.xz file but without the ".tar.xz" extension.
If you see an error message saying "tar: command not found", your system does not have tar installed. This is rare on modern Linux distributions, but if it happens, you can install it using your system's package manager. On Ubuntu or Debian, type sudo apt install tar. On Fedora or Red Hat, type sudo dnf install tar.
Finding and reading installation instructions
Navigate into the extracted folder by typing cd foldername. Once inside, type ls to see what files are there. Look for a file named README, INSTALL, or INSTALL.txt — these files contain the specific steps for installing whatever software is in this archive. Open one of these files with a text editor by typing cat README or cat INSTALL.
Read through these instructions carefully. They will tell you whether the software needs to be compiled, whether it has dependencies you need to install first, and where the final software should be placed on your system. Different projects have different requirements, so following the included instructions is more reliable than guessing.
Compiling from source if required
Many tar.xz files contain source code that must be compiled before it can run. The instructions will tell you if this is necessary. The typical sequence is three commands run one after the other:
- ./configure — This checks your system to make sure you have everything needed and prepares the build.
- make — This compiles the source code into a working program. This step can take several minutes.
- sudo make install — This copies the compiled program to system folders where it can be run from anywhere. The sudo part means you are running it with administrator permissions, which is usually required for this step.
If any of these commands fails, read the error message carefully. It usually tells you what is missing. Common issues include missing development libraries or an older version of a required tool. The README file often lists these dependencies at the top, so check there first before trying to solve the error yourself.
Installing pre-compiled software
Not all tar.xz files contain source code. Some contain software that is already compiled and ready to run. The README will make this clear. In these cases, you usually just need to move the extracted folder to a standard location or run the program directly from where you extracted it.
If the instructions say to move the folder, you might type something like sudo mv foldername /opt/ to move it to the /opt directory, which is a common place for manually installed software. Or you might run the program directly by typing ./programname from inside the extracted folder. Again, the README tells you which approach to use.
Cleaning up after installation
Once the software is installed and working, you can delete the original tar.xz file to save disk space. Type rm filename.tar.xz to remove it. Keep the extracted folder until you have confirmed the software runs correctly — if something goes wrong, you may need to reinstall or troubleshoot using the files inside.
If you installed the software using make install, the extracted folder can usually be deleted as well once installation is complete, since the compiled program is now in system directories. However, some software may reference files in the original folder, so check the README to be sure. When in doubt, keep the extracted folder for a few days until you are confident everything is working.
Frequently Asked Questions
What if I get a "permission denied" error?
This usually means you are trying to write to a folder where you do not have permission. If the error happens during make install, use sudo make install instead. If it happens during extraction, make sure you are extracting to a folder you own, like your home directory or Downloads folder, not a system folder.
Can I extract a tar.xz file using the file manager instead of the terminal?
Some Linux file managers can extract tar.xz files by right-clicking and selecting "Extract" or similar. This works for basic extraction, but you will still need the terminal to run the installation commands afterward. Using the terminal from the start is more straightforward.
What does the tar -xf command actually do?
The -x flag tells tar to extract files, and the -f flag tells it which file to extract from. You could also use tar -xvf with a v flag to see a list of files as they are extracted, which can be helpful if you want to watch the progress.
Do I need to be in the same folder as the tar.xz file to extract it?
No. You can extract a tar.xz file from any folder by typing the full path to the file, like tar -xf ~/Downloads/filename.tar.xz. But it is simpler to navigate to the folder first using cd, then run the extraction command.
What if the extracted folder is very large and I am running out of disk space?
Check how much space the extracted folder uses by typing du -sh foldername. If you need to free up space and the software is already installed, you can delete the extracted folder. But if installation failed, you may need to keep it to troubleshoot or try again.