The tar.bz2 format is one of the most popular formats for file compression in Linux systems. When you need to compress a collection of files and folders together and store them in a compact format, this format is a suitable option. It’s a tar package that has been compressed using the bzip2 algorithm.
What is tar and why is it the primary tool for working with archives in Linux?

In the world of Linux and Unix, tar is one of the most essential tools for file and archive management. The name “tar” comes from the combination of the words Tape Archive. This is because it was initially designed to archive files on magnetic tapes.
If you want to combine, store, transfer, or back up multiple files and folders, tar is a reliable and widely used choice. In other words, a “tarball” file is an archive created by tar, acting like a digital box that holds several files and directories along with their structure, permissions, and metadata (ownership, date, access level).
Common Uses of tar
- Backup and Archiving: When you need to save a copy of directories or projects.
- Transfer Between Servers or Systems: Because a tarball preserves the entire directory structure and permissions, moving between servers is easier and more reliable.
- Compression with Archiving: By combining tar with compression programs like gzip or bzip2, archives can be stored or transferred with a smaller file size.
What is bzip2? High-Performance Compression in Linux

tar and bzip2 are complementary: When you need to compress and archive multiple files or folders, you typically first create an archive with tar and then compress it with bzip2. bzip2 is a compression tool in itself, not an archiver. Therefore, it cannot directly package multiple files and folders. The biggest advantage of bzip2 over older options like gzip or ZIP is that it shrinks files with a higher compression ratio.
Therefore, when your goal is to store large archives with the smallest possible size (such as backups or project archiving), bzip2 is a suitable choice.
How to Extract (Unzip) a tar.bz2 File in Linux?

Before extracting the files from the archive, you can view the list of files using the following command:
tar -tf file.tar.bz2
The -t option displays the contents list, and -f specifies the archive file name. If you want to see more information such as file size, date, and permissions, you can use the -v option:
tar -tvf file.tar.bz2
This will show information such as the type of permissions, ownership, size, and creation date of each file in the output.
Extracting (Unzipping) the tar.bz2 Archive

To fully extract an archive, simply enter the following command:
tar -xf file.tar.bz2
The tar command automatically detects that the archive is compressed with bzip2 and performs the extraction process accordingly.
If you want to extract the files while displaying their names, also use the -v option:
tar -xvf file.tar.bz2
By default, files are extracted to the current directory. If you want to extract them to a specific folder, you can use the -C option:
tar -xf file.tar.bz2 -C /path/to/destination
Extracting Specific Files or Folders Within an Archive

Sometimes, you only need to extract specific files or folders from an archive, not everything. In this case:
tar -xf file.tar.bz2 dir1/file1 dir2
In this command, dir1/file1 and dir2 are the exact paths within the archive.
Extracting from stdin

If you are downloading a tar.bz2 file directly from the internet and don’t want to save it first, you can extract it directly by combining a download tool and tar. For example:
wget -O - | tar -xj
In this method, the output of wget is piped to tar, and the -j option tells tar that the archive is compressed with bzip2.
Creating a new tar.bz2 archive

If you want to compress and archive files or folders, use the following command:
tar -cjf files.tar.bz2 folder1 folder2 file1
-c: Create an archive-j: Use bzip2 compression-f: Specify the archive file name
For example, with this command, all the contents of folder1, folder2, and also file1 will be placed inside the files.tar.bz2 file.
The tar.bz2 format provides a combination of packaging (tar) and compression (bzip2), which is very suitable for large archives or multi-file collections. Using the tar tool in Linux, you can easily:
- Check the contents of the archive before extracting it
- Extract the archive completely
- Extract only a specific file or folder from the archive
- Create a new archive with bzip2 compression
If you are familiar with these concepts, managing compressed and archived files on servers or personal systems will be much simpler and more professional.
“`html “`