Linux/Unix: How To Extract and Decompress a .bz2/.tbz2 File

To extract and decompress a .bz2 or .tbz2 file in Linux or Unix, you can use the tar command with the j option to handle bzip2 compression:

tar xvjf file.tbz2

or

tar xvjf file.bz2

Here, x option is used to extract the contents of the archive, v option is used to display verbose output, and j option is used to specify bzip2 compression. The f option is used to specify the file name.

This will extract the contents of the archive and place them in the current directory.

Alternatively, you can use the bzip2 command to decompress the .bz2 file, and then extract the contents of the resulting .tar file using the tar command:

bzip2 -d file.bz2
tar xvf file.tar

Leave a Comment