How to Extract or Unzip Tar Bz2 (.tar.bz2 | .tbz2) Files on Ubuntu Linux

|

|

This post is a tutorial on how to extract or unzip archived tar files compressed with bzip2 compression, ending in .tar.bz2 or .tbz2 on Ubuntu 18.04 LTS. The tutorial explains the tar command, its syntax, options, examples of its use, and how to handle errors during extraction. By the end, learners are expected to competently…

This brief tutorial shows students and new users how to extract or unzip archived tar files compressed with bzip2 compression ending in .tar.bz2 or .tbz2  on Ubuntu 18.04 LTS.

The tar command creates, maintains, and extracts files archived in tar format on Linux systems, including Ubuntu. “Tar” stands for tape archive.

If you’re a student or new user looking for a Linux system to start learning on, the most accessible place to start is Ubuntu Linux OS. It’s a great Linux operating system for beginners.

Ubuntu is an open-source Linux operating system that runs on desktops, laptops, servers, and other devices.

About tar command:

The tar command creates, maintains, and extracts files archived in tar format on Linux systems, including Ubuntu. “Tar” stands for tape archive. It is one of the many archiving file formats available.

Syntax:

The syntax is the rule and format of how the tar command can be used. These syntax options can be reordered, but a straight format must be followed.,.

Below is an example syntax of how to use the tar command.

tar [OPTION.] [FILE].

Options:

The command line options are switches or flags that determine how the commands are executed or controlled. They modify the behavior of the commands. They are separated by spaces and followed after the commands.

Below are some options for the tar command:

   FILE.Replace FILE.. with the name of the archived file you want to extract.
-x, –extract, –get
Use the -x or –extract or –get to extract files from an archive
-f, –file=ARCHIVEUse the -f or –file to specify the use of archive file to extract
-v, –verbose Use the -v or –verbose to verbosely list files being processed
-j, –bzip2Use the -j or –bzip2 to filter the archive through bzip2 compression
-t, –listUse the -t or -list to list the content of an archive
–helpDisplay a help message and exit.

Examples:

Below are some examples of how to run and use the tar on Ubuntu Linux.

Simply run the tar command to invoke it.

To extract a tar archive file compressed with the bz2 compression algorithm, you run the command below:

tar -xvjf archive.tar.bz2

The command above will extract the archive file into the current working directory. The -j option tells tar that the file is compressed with bzip2.

A file is compressed with .tar.bz2, and you run the tar command without a decompression option; the command will error out and tell you to use the -j option for it to be successful.

If you wish to extract the above-archived file into a specific directory, you run the commands below:

tar -xvjf archive.tar.bz2 -C /home/myaccount/public

The command above will extract the archive file into the /home/myaccount/public directory or folder.

Suppose you want to list the content of an archived file compressed with tar.bz2, you use the -t or –list command options.

tar -tf archive.tar.bz2

That should list the content of the archive. Always use the -f option to tell the command you’re working with a file archive.

When you run su with the –help option, you’ll see the help text below:

Usage: tar [OPTION.] [FILE].
GNU 'tar' saves many files together into a single tape or disk archive, and can
restore individual files from the archive.

Examples:
  tar -cf archive.tar foo bar  # Create archive.tar from files foo and bar.
  tar -tvf archive.tar         # List all files in archive.tar verbosely.
  tar -xf archive.tar          # Extract all files from archive.tar.

 Local file name selection:

      --add-file=FILE        add given FILE to the archive (useful if its name

That’s it!

Congratulations! You’ve learned to use the tar command to extract archived compressed with .tar.bz2 or .tar.bzip2 on Ubuntu.

You may also like the commands below:

Like this:



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.