HiBlog Linux and Windows Server
How to Extract a .tar.bz2 Archive on Linux
- Ali GhanimatiAuthor
- Last updated
- 2 minutesReading time
- 1,238Views
- Ali Ghanimati
- Last updated:
- 2 min read
- 1,238 views
A .tar.bz2 file is a tar archive compressed with bzip2. GNU tar can list and extract it directly, so you do not need to create an uncompressed intermediate file. Listing the contents first helps you learn the paths and avoid overwriting an existing directory.
Use a separate destination with enough space. Uncompressed files may take much more space than the archive. When handling an archive from someone else, inspect file names and paths and avoid extracting it as an administrator.
List the archive
tar -tjf archive.tar.bz2Here -t lists entries, -j selects bzip2, and -f identifies the archive. Use the exact paths in this output if you plan to extract individual files.
Extract all files
mkdir extracted && tar -xjf archive.tar.bz2 -C extractedThe example uses a new directory and extracts only if its creation succeeds. -x requests extraction, and -C changes the destination directory.
Extract a single entry
For a new or existing intended destination called extracted, use the exact member path you saw in the listing:
tar -xjf archive.tar.bz2 -C extracted -- docs/guide.txtCheck the output and open the extracted file. If tar reports a missing member, look for differences such as a leading ./ or a top-level directory. GNU tar manual for Ubuntu.


