If you’ve never seen a .tar.bz2
file before, don’t worry—it’s just a compressed archive used on Linux and Unix-based systems to save space. A .tar.bz2
file is created in two steps—first, a .tar
archive bundles multiple files, then bzip2
compresses it to save space. This format is commonly used in Linux and Unix systems for backups, software distribution, and large datasets. Knowing how to extract these compressed archives helps with file management and storage efficiency.
Learning to extract tar.bz2 files can save you a lot of time and headaches, especially when dealing with large file archives. In this article, we’ll explore simple ways to open and extract these files on Linux, Windows, and macOS.
What are tar.bz2 Files?
The tar.bz2 file format combines the power of two tools:
- Tar: Short for “tape archive,” this utility collects multiple files into a single archive, preserving directory structures and file metadata.
- Bzip2: A compression algorithm that reduces the size of the archive, making it easier to store or transfer.
A .tar.bz2
file is simply a .tar
archive that’s been compressed using the bzip2
algorithm, making it ideal for reducing file size while keeping the original directory structure intact.
When handling Linux archive files, choosing between .tar.gz
and .tar.bz2
depends on your priority. If you need faster extraction speeds, gzip
is the better choice. If smaller file size matters, bzip2
offers better compression, making it ideal for long-term storage and large backups.
Comparing tar.bzip2 vs tar.gzip
Performance
Performance tests comparing .tar.gz
and .tar.bz2
show that gzip
is significantly faster, especially when compressing large directories. In benchmark tests on a 1GB dataset:”
- tar.gz (gzip) → Compress: ~35 seconds | Extract: ~12 seconds
- tar.bz2 (bzip2) → Compress: ~95 seconds | Extract: ~28 seconds
While bzip2
achieves up to 20% better compression ratios, it takes nearly 3x longer to compress files. If you prioritize quick extraction, gzip
is the better option, while bzip2
is ideal for archiving large files.
Want to learn more? Check out the man page for the tar
command.
Prerequisites for Extracting .tar.bz2 files
Before you can extract tar.bz2 files, ensure the following:
- Tools and utilities: Most systems already include the necessary tools like
tar
andbzip2
. - Command-line access: For Linux and macOS, having Terminal access is essential.
- File manager: A GUI-based approach can simplify the process if you prefer not to use commands.
On Windows, tools like 7-Zip are invaluable for handling these archives. Having the right tools ensures you can decompress tar.bz2 files without any hassle.
Extracting tar.bz2 Files on Linux
Using the Command Line
Using the Terminal is the fastest way to extract .tar.bz2
files in Linux distributions like Ubuntu, Debian, and Fedora.
- Open a Terminal window and navigate to the file location.
- Use the following command to extract the contents of the tar.bz2 file:
tar -xvjf filename.tar.bz2
Breakdown of options:
-f
→ Specify the filename-x
→ Extract files-v
→ Show progress (optional)-j
→ Usebzip2
compression
By default, extracted files land in the same folder as the .tar.bz2
archive, but you can specify a different location if needed.
Using File Managers
If you prefer a graphical interface, most Linux distributions offer GUI-based file managers that can handle tar.bz2 files.
- Navigate to the location of your tar.bz2 file.
- Right-click the file and select “Extract Here” or a similar option from the context menu.
- The contents will be extracted to the same directory or a subfolder, depending on your system settings.
Pro Tip: Ensure your file manager has the necessary archive support. Tools like Ark (for KDE) or File Roller (for GNOME) work seamlessly with compressed files.
Table 1: Command Line Options for tar.bz2 Files
Option | Description | Example Usage |
---|---|---|
-x |
Extract files from the archive | tar -xvjf file.tar.bz2 |
-v |
Verbose: Show detailed output | tar -xvjf file.tar.bz2 |
-j |
Use bzip2 for compression or decompression | tar -xvjf file.tar.bz2 |
-t |
List contents of the archive without extracting | tar -tvjf file.tar.bz2 |
-f |
Specify the file name to work with | tar -xvjf file.tar.bz2 |
Extracting tar.bz2 Files on macOS
Using Terminal
macOS Terminal works just like Linux for extracting .tar.bz2
archives, making it easy to open compressed files without extra software.
- Open Terminal (you can find it in Applications > Utilities).
- Navigate to the folder containing your tar.bz2 file using the
cd
command:cd /path/to/your/file
tar -xvjf filename.tar.bz2
Breakdown of options:
-f
→ Specify the filename-x
→ Extract files-v
→ Show progress (optional)-j
→ Usebzip2
compression
Just replace filename.tar.bz2
with your actual file name. The extracted files will appear in the same folder.
Using The Unarchiver
For users who prefer GUI-based tools, The Unarchiver is an excellent option:
- Download and install The Unarchiver from the Mac App Store.
- Open the app and set it as the default for handling tar.bz2 files.
- Double-click the tar.bz2 file, and The Unarchiver will extract its contents to a folder.
This method is ideal for those who aren’t comfortable using the command line but still need to manage bzip2 compressed files.
Extracting tar.bz2 Files on Windows
Using 7-Zip
Since Windows lacks built-in support for .tar.bz2
files, free tools like 7-Zip or WinRAR make extraction simple.
- Download and Install 7-Zip:
- Go to the official 7-Zip website.
- Download the appropriate version for your system (32-bit or 64-bit).
- Install the application.
- Extract the tar.bz2 File:
- Right-click on your tar.bz2 file and select “7-Zip” from the context menu.Choose “Extract Here” or “Extract to [Folder Name]” depending on where you want the files.
Since
.tar.bz2
uses two compression layers, extract the.tar
file first, then extract its contents. - Once complete, your files will be available in the selected directory.
Using Command Prompt with 7-Zip
For those comfortable with the command line, 7-Zip also supports command-based extraction:
- Open Command Prompt (type
cmd
in the Start menu). - Navigate to the directory containing the tar.bz2 file:
cd C:\path\to\file
- Use the following commands:
- To extract the tar.bz2 file:
7z e filename.tar.bz2
- To extract the tar archive:
7z x filename.tar
- To extract the tar.bz2 file:
This method is efficient for batch processing or advanced workflows.
Extracting Specific Files from a tar.bz2 Archive
Need only a few files from a large .tar.bz2
archive? You can extract specific files without unpacking everything.
Listing the Contents
Check the archive’s contents before extracting to find the exact file you need:
tar -tvjf filename.tar.bz2
-t
: Lists the contents without extracting.-v
: Shows details like file size and permissions.-j
and-f
: Indicate bzip2 compression and specify the filename.
Extracting Specific Files
To extract a particular file or directory, use the following command:
tar -xvjf filename.tar.bz2 path/to/file
Replace path/to/file
with the exact name or directory you want to extract.
Example Use Case:
If your archive contains a folder named docs
and you only want that:
tar -xvjf archive.tar.bz2 docs/
This is especially useful when working with large archives where you don’t need everything.
Example: Extracting Files to a Specific Directory
Add to the Linux/macOS Command Section:
To extract a .tar.bz2
archive directly into a specific folder, use the -C
flag:
tar -xvjf filename.tar.bz2 -C /path/to/destination
Example Use Case:
If you want to extract backup.tar.bz2
into /home/user/documents
, run:
tar -xvjf backup.tar.bz2 -C /home/user/documents
This ensures the extracted files go directly into the target directory instead of cluttering the current folder.
Common Errors and Troubleshooting
“Command not found” Errors
If you see errors like tar: command not found
or bzip2: command not found
, it means the required tools aren’t installed.
- On Linux, use your package manager to install them:
sudo apt install tar bzip2 # For Debian-based systems sudo yum install tar bzip2 # For Red Hat-based systems
“Cannot open file” Errors
This usually happens when the file path is incorrect or you lack permissions:
- Double-check the file path.
- Use
sudo
if you’re on Linux and need admin rights.
Corrupted Files
If the .tar.bz2
file won’t open due to corruption, verify its integrity before attempting another extraction.
- Verify the file’s integrity by checking its checksum (e.g.,
sha256sum
). - Re-download the file if necessary.
How to prevent extraction errors:
- Always use updated tools.
- Ensure you have enough disk space before extracting large archives.
FAQs
What is a tar.bz2 file?
A tar.bz2 file is a compressed archive combining tar (for bundling files) and bzip2 (for compression). It’s commonly used on Linux and Unix-based systems to reduce file size while preserving directory structures.
How do I extract a tar.bz2 file on Windows?
Use 7-Zip or WinRAR. Right-click the file, choose Extract Here, then repeat the process for the extracted .tar
file to get the final contents.
Can I extract a tar.bz2 file without Terminal?
Yes, Linux and macOS users can use File Roller (GNOME) or Ark (KDE). Windows users can use 7-Zip or The Unarchiver on macOS for a GUI-based approach.
What if I only need one file from a tar.bz2 archive?
Run tar -xvjf archive.tar.bz2 filename
in Terminal, replacing “filename” with the file you need. This extracts only the specified file without unpacking everything.
Why am I getting a “command not found” error?
Your system may not have tar
or bzip2
installed. On Linux, install them using sudo apt install tar bzip2
(Debian) or sudo yum install tar bzip2
(Red Hat).
Conclusion
Whether you’re on Linux, macOS, or Windows, extracting tar.bz2 files is a simple process once you know the right tools and commands. From the command line to GUI-based options like 7-Zip and The Unarchiver, you have multiple ways to get the job done.
Now that you know how to handle tar.bz2 extraction, practice these methods and save time managing your files. You’ll be amazed at how much smoother your workflows become!
Introduction
You can use the tar command to generate and extract tar archives. Gzip
, bzip2
, lzip
, lzma
, lzop
, xz
, and compress
are just a few of the compression applications it supports.
One of the most often used techniques for compressing tar files is Bzip2. The name of a tar archive compressed with bzip2 should end in either .tar.bz2 or .tbz2.
In this tutorial, you will use the tar
command to extract (or unzip) tar.bz2 and tbz2 archives. We will also address a few FAQs on how to extract (Unzip) Tar Bz2 File.
The tar program comes pre-installed on most Linux variants and macOS.
Use the --extract
(-x)
option and supply the archive file name after the -f
option to extract a tar.bz2 file:
tar -xf archive.tar.bz2
The tar program automatically determines the type of compression and extracts the archive. The same command may be used to extract tar archives compressed using different techniques, such as .tar.gz
or .tar.xz
.
If you’re a desktop user who prefers not to utilize the command line, you can use your file manager instead. To extract (unzip) a tar.bz2
file, simply right-click it and choose «Extract.» To extract tar.bz2
files, Windows users will need to use the 7zip program.
Use the -v
option to get more detailed output. This option instructs tar
to print the names of the files being extracted to the terminal.
tar -xvf archive.tar.bz2
Tar
extracts the contents of an archive in the current working directory by default. To extract archives in a specific directory, use the --directory
(-C)
option:
To extract the contents of an archive to the /home/vega/files
directory, for instance, type:
tar -xf archive.tar.bz2 -C /home/vega/files
Append a space-separated list of file names to be extracted after the archive name to extract a specific file(s) from a tar.bz2 file:
tar -xf archive.tar.bz2 file1 file2
When extracting files, you must use their exact names, including the path, as displayed by the --list
(-t)
option.
Extracting numerous files from an archive is the same as extracting one or more directories:
tar -xf archive.tar.bz2 dir1 dir2
If you try to extract a file that doesn’t exist in the archive, you’ll get an error notice that looks like this:
tar -xf archive.tar.bz2 README
Output
tar: README: Not found in archive
tar: Exiting with failure status due to previous errors
You can use the --wildcards
option to extract files from a tar.bz2 file using a wildcard pattern. To prevent the shell from reading the pattern, it must be quoted.
To extract only the files with names ending in .md
(Markdown files), for example, use:
tar -xf archive.tar.bz2 --wildcards '*.md'
You must specify the decompression option when extracting a compressed tar.bz2 file from standard input (often via piping). The -j
option instructs tar
to compress the file using the bzip2 algorithm.
We’ll use the wget
command to get the Vim sources and pipe the output to the tar command in the example below:
wget -c ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2 -O - | sudo tar -xj
If you don’t specify a decompression option, tar will recommend the options to you:
Output
tar: Archive is compressed. Use -j option
tar: Error is not recoverable: exiting now
List tar.bz2 File
Use the --list
(-t)
option to list the contents of a tar.bz2 file:
tar -tf archive.tar.bz2
You will get an output like below:
Output
file1
file2
file3
Tar
will print more information if you use the --verbose
(-v)
option, such as the owner, file size, timestamp, and so on:
tar -tvf archive.tar.bz2
Output
-rw-r--r-- linuxize/users 0 2019-02-15 01:19 file1
-rw-r--r-- linuxize/users 0 2019-02-15 01:19 file2
-rw-r--r-- linuxize/users 0 2019-02-15 01:19 file3
What is a tar.bz2 file?
A tar.bz2 file is a compressed archive file that combines multiple files into a single compressed file using the tar and bzip2 compression algorithms.
Can I extract a tar.bz2 file without installing additional software?
No, you need to have a utility like tar installed on your system because it is required to extract the contents of a tar.bz2 file.
What is the command for extracting a tar.bz2 file?
The command for extracting a tar.bz2 file is tar -xjf filename.tar.bz2
.
Can I specify a destination directory while extracting the tar.bz2 file?
Yes, you can specify a destination directory by using the -C
flag followed by the desired directory path.
Can I extract only specific files from a tar.bz2 file?
Yes, you can extract specific files by providing their names or patterns as arguments to the tar
command.
How do I view the contents of a tar.bz2 file without extracting it?
To view the contents of a tar.bz2 file without extracting, you can use the tar -tf filename.tar.bz2
command.
Will extracting a tar.bz2 file overwrite existing files?
Yes, if a file with the same name already exists in the extraction directory, it will be overwritten during the extraction process.
Conclusion
The tar.bz2 file is a Bzip2 compressed Tar archive. Use the tar -xf
command followed by the archive name to extract a tar.bz2 file.
If you have any queries, please leave a comment below and we’ll be happy to respond to them.
-
Что такое Tar
-
Как установить, создать архив Tar и распаковать его в Windows
-
Как запаковать архив tar.gz и tar.bz2 в Ubuntu, Debian, CentOS
-
Как распаковать архив tar.gz и tar.bz2 Ubuntu, Debian, CentOS
-
Просмотр архивов tar в Linux
-
Иные возможности tar
Tar — это популярный файловый архиватор в Unix/Linux системах. Tar
зачастую используется вместе с архиваторами GZip
или BZip2
, так как они отлично взаимодополняют друг друга: Tar
не может сжимать файлы, только собирать их в одни архив, а GZip
и BZip2
не могут сжимать несколько файлов одновременно, поэтому если вам нужно запаковать несколько файлов и директорий, сначала они собираются в один несжатый архив с помощью Tar
, который сохранит их некоторые атрибуты, например такие, как права доступа, а затем этот архив сжимается с помощью GZip
или BZip2
. Весь процесс запускается одной консольной командой, про которые далее.
Как установить, создать архив Tar и распаковать его в Windows
Чтобы использовать Tar в Windows, нужно воспользоваться одним из следующих вариантов:
- Установить Far Manager.
Инструкция по созданию и распаковке архива.tar
с помощью Far Manager:-
Теперь просто выделяете ПКМ (правой кнопкой мыши) или кнопкой клавиатуры Insert нужные вам файлы и папки и жмёте
Shift + F1
, затем выбираете нужный формат (в нашем случае, TAR) и создаёте архив:Создание архива в Far Manager
При желании, в поле Добавить к архиву можно изменить название архива, а в поле Ключи можно ввести пароль от него.
-
Чтобы распаковать архив Tar, просто выделяете ПКМ или Insert нужный архив и жмёте
Shift + F2
Как распаковать Tar в Far Manager
В поле Распаковать в вводится путь, куда распаковать архив. Если нужно распаковать в текущую папку, нужно оставить поле
Распаковать архив
пустым. Если архив запаролен, пароль вводится в поле Пароль.
-
Теперь просто выделяете ПКМ (правой кнопкой мыши) или кнопкой клавиатуры Insert нужные вам файлы и папки и жмёте
- Также, можно обойтись без Far Manager, установив 7-Zip
Скачать 7-zip архиватор
Всё управление — создать архив и распаковать его — через ПКМ и Проводник Windows
Как запаковать архив tar.gz и tar.bz2 в Ubuntu, Debian, CentOS
tar cfvz archive.tar.gz *.php
где tar
— команда, cfvz
— ключи, archive.tar.gz
— имя будущего архива, *.php
— список файлов, которые нужно заархивировать.
Список можно заменить директорией, которую нужно запаковать целиком, для этого указываем путь до неё, абсолютный или относительный
tar cfvz archive.tar.gz /forpack
Теперь подробнее про ключи
-с
— команда, которая означает «создать архив»-f
— команда на упаковку файлов и директорий в один файл архива-v
— включает визуальное отображение процесса архивации-z
— использовать для сжатияGZip
Также, можно использовать для сжатия BZip2
. Для этого нужно использовать ключ -j
вместо -z
.
В этом случае, команда для запаковки tar.bz2
будет выглядеть так
tar cfvj archive.tar.bz2 /forpack
Вместо GZip
и BZip2
можно пользоваться иными архиваторами, для этого просто нужно подобрать соответствующий ключ.
Чтобы исключить определённый каталог или файл из архива, можно воспользоваться ключом --exclude
.
Сначала переходим в нужный каталог, затем используем следующую команду:
tar cfvz wp-content.tgz wp-content --exclude=wp-content/updraft --exclude=wp-content/uploads --exclude=wp-content/cache
Тут мы запаковываем каталог /wp-content/
на WordPress, исключая раздел Updraft wp-content/updraft
, раздел Загрузки wp-content/uploads
и Кеш wp-content/cache
.
Важный момент — чтобы исключить ошибки, не указывайте слеш
/
в конце пути исключаемого каталога.
Как распаковать архив tar.gz и tar.bz2 Ubuntu, Debian, CentOS
Чтобы распаковать архив tar.gz
или tar.bz2
, в команде нужно заменить -с
на ключ -x
, а также указать путь до архива, абсолютный или относительный
Команда для распаковки архива в текущую директорию выглядит так
tar xfvz archive.tar.gz
С помощью ключа -С
можно указать путь, куда нужно распаковать архив
tar xfvj archive.tar.bz2 -C /var/www
Просмотр архивов tar в Linux
Для просмотра содержимого архивов можно использовать ключ -t
tar -tf archive.tar.bz2
Будет выведен список файлов и директорий в архиве. При добавлении ключа -v
также будет выведена подробная служебная информация о правах доступа, размерах файлов и прочем.
Иные возможности tar
Tar
имеет много дополнительных возможностей, к примеру, добавление файлов в существующий архив, исключение некоторых файлов и директорий при запаковке архива и так далее. Подробнее вы можете узнать о них при помощи команды
tar --help
Загрузка…
- Home
- Features
- Downloads
- Support
- Developers
- Contact
Description of TAR archive extractor
- View RPM package files structure.
- Open, browse, view, and extract RPM package files.
- Use Altap Salamander viewers to view inner files.
- Supported UNIX archives:
- TAR — (GNU) tar (tape archive) compatible format.
- GZ (GZIP) — (GNU) zip compressed file format.
- TGZ — (GNU) Tar archive compressed with (GNU) zip.
- BZ2, BZ — BZip, compression program similar to (GNU) zip (gzip), better compression.
- TBZ — GNU Tar archive compressed with BZip compression.
- Z — Archive compressed with old unix Compress.
- TAZ — Tar archive compressed with unix compress.
- RPM — Red Hat Linux package distribution archive.
- DEB — Debian software package distribution archive.
- CPIO — Tape archive format similar to tar.
- All archives supported by Altap Salamander: ZIP, J, RAR, ARJ, LZH, LHA, LZS,
PAK, RPM, DEB, TAR, TGZ, GZ, TBZ, BZ, BZ2, CPIO, TAZ, Z, CAB, EML, B64, UUE,
XXE, HQX, NTX, CNM, UC2, and 7Z
How to open, view, browse, or extract TAR files?
- Download and install Altap Salamander 4.0 File Manager.
- Choose the desired file and press the F3 (View command).
- Press the Enter key to open archive.
- To view inner file using associated viewer press the F3 key (Files / View command).
- To extract inner file: select it and press the F5 key (Files / Copy command).
- For more details see Opening Archive Files in Altap Salamander Help.
Why choose Altap Salamander as file manager?
- All-in-one solution.
- Unified design and control.
- Intuitive and effective interface.
- Power user functionality, short learning curve.
- Keyboard and mouse shortcuts for most commands.
- High quality software with emphasis on error states.
- Superior quality with emphasis on safety of your files during error states.
File manager Altap Salamander in a nutshell
- Altap Salamander is a native Windows application with modern and clean design.
- Using graphic instead of text mode brings easy to use and powerful user interface.
- Well-established shortcuts from Norton Commander and Windows.
- Drag&Drop support, mouse shortcuts for most frequent commands.
- Handy support for clipboard: you can copy file name with full path on clipboard.
- Quick search is really quick: just start typing the name of file you are looking for.
- Advanced Select/Unselect commands including Save and Load Selection.
- Operations are started on background; you needn’t wait until operation is finished.
- Thumbnails view mode for digital camera users, graphic designers, web masters, etc.
- PictView viewer for more than 40 bitmap file formats.
- Fast text and binary viewer with hexadecimal and ASCII modes. Large files over 4GB supported.
- Support for Regular Expressions in viewers and Find. Wildcards for easy filenames selecting.
- Database viewer for DBF and CSV files, Multimedia viewer for MP3, OGG or STM files.
- Portable Executable viewer will say you all about EXE or DLL files.
- With Internet Explorer viewer you can quickly display your HTML file.
- Well-arranged Find dialog with many find options including searching for duplicates.
- Make File List command allows you export files and directories listings to text file.
- List of shared directories with option to stop sharing.
- Changing file and directory names to lower, upper or mixed case.
- Converting end of line (EOL) characters between Windows, MAC and UNIX.
- Changing coding of text files (CP1250, CP852, KOI-8, Kamenicti, EBCDIC, etc.).
- List of recently opened files and working directories for easier access.
- Comparing directory trees by name, date, time, attributes, or by content.
- Internal support for most major archives: ZIP, RAR, ARJ, LZH, LHA, LZS, 7-ZIP, TAR, TGZ, BZ, BZ2, RPM, CPIO, Z, PK3, JAR, and Microsoft CAB.
- Possibility to make self-extracting archives with custom icons, texts and behavior.
- Open CD or DVD ISO image files, browse all sessions, view and extract contained files.
- Open and extract MIME/Base64 email messages. yEncode and BinHex decoder.
- Open and browse Outlook Express DBX archives, save email attachments.
- User friendly configuration. All options are accessible from dialog boxes or menu.
- Open plugin architecture to enable third-party plugins and extensions.
- Advanced file comparator for text and binary files will display differences.
- Advanced batch renamer for easy renaming of your files and directories.
- FTP Search for searching on FTP servers.
- Registry editor for browsing, viewing, and editing of your Windows Registry.
- Support for splitting and combining files.
- WinSCP plugin based on famous SFTP and SCP client.
- FTP client with clever non-blocking design allows postpone solving of errors.
- Checksum plugin will calculate and verify CRC32 (SFV) and MD5 file checksums.
- Files encryption and decryption using strong encryption algorithms: AES (Rijndael), Blowfish, and TripleDES in either ECB or CBC mode.
- Open FAT 12, 16, or 32 disk image, browse directories and view or extract required files.
- Undelete plugin for recovering deleted files from your FAT or NTFS partitions.
- Windows Mobile plugin for accessing Pocket PC, Pocket PC Phone Edition, Smartphone, and Windows CE devices from Altap Salamander.
- And much much more… download Altap Salamander 4.0 and try it yourself.