How To: Decompress tar.bz2 Files

Today’s article will be simple enough, though it will have limited application, as we discuss how to decompress tar.bz2 files. While this is certainly suitable for a newbie and easy enough to learn, many folks will just choose the GUI route.

Of course, you’re not always able to use a GUI. Sometimes there’s no way to do this graphically and you’ll have to do this in the terminal – perhaps over SSH. In fact, with my crappy bandwidth, I like to upload compressed files and then extract them on the server itself. This sort of thing works for me.

We have already talked about how you go about compressing and decompressing .bz2 files. You can read that article here:

How To: Compress And Decompress .bz2 Files

This time we’re going to be working with ‘tar.bz2’ files – and decompressing these files is different than what you’ll have learned from the previous article.

What is ‘tar’?

A tar file stands for ‘Tape Archiver’ and is a compression method as old as time itself. Well, probably not that long – but a very long time. It’s sometimes referred to as a ‘tarball’ and Wikipedia tells me that it has been around since early 1979.

Here’s a good quote from Wikipedia:

The archive data sets created by tar contain various file system parameters, such as name, timestamps, ownership, file-access permissions, and directory organization.

The blurb goes on to mention that POSIX has supplanted tar in favor of pax, but when was the last time you saw a .pax file? So, tar is still widely in use.

The man page describes tar as:

tar – an archiving utility

Which is exactly the kind of thing we’re looking for. Imagine that?

What is .bz2?

If you read the link above, you’d know the answer to this question. I assume my readers are creatures of habit, so they’ve done no such thing. They’re probably skipping this section entirely and reading just the middle of the article.

Anyhow, in the previous .bz2 article, I mentioned this:

If you don’t already know, .bz2 files are bzip2 files. You’ll find that bzip2 is an opensource compression program that gets some regular usage, and you’ll sometimes find downloaded files that are compressed with this format. You may also, for compatibility reasons, want to compress files with bzip2 to share with other users who are already set on using the .bz2 format.

That sums it up nicely, though you don’t have to worry about that. See, with this particular command and these particular tar.bz2 files, you can decompress (extract) the files in one fell swoop. 

Just for the record, you should also know that the bzip2 man page defines itself like so:

bzip2, bunzip2 – a block-sorting file compressor, v1.0.8

Your man page might be different, saying that it’s a different version. Either way, that’s what bzip2 is and that’s what it’s used for. 

So, with all that in mind, we can get to the important bits of the article…

Decompress tar.bz2 Files:

As I mentioned in the intro, you can likely do this with your built-in GUI file extraction tool (often file-roller) easily enough. However, again as suggested in the intro, we’ll be doing this in the terminal. In most cases, you can press CTRL + ALT + T to open the terminal.

With your terminal open in the correct directory, you can start by listing the files in the archive without actually decompressing them. That command would look like this:

That will happily spit out a list of all the files included. If you want, you can make the output more verbose by adding the -v flag, so that it’d be tar -tvf for example.

Next, I assume you want to decompress the tar.bz2 files, that is to extract the files within. To do that, you’d want this command:

Finally, I’ll give you a fun command. Let’s say you only want to extract files of a certain type, that is with a certain extension, from your tar.bz2 file. Well, you can do that and it’s easily done. Just use this command:

That command would decompress and extract all the files with .jpg as their extension. You can use any extension there, being sure to use the * to indicate a wildcard even though you already specified it with the –wildcard flag. It is what it is.

There’s more that you can do, but those are the ways I figure most folks are going to decompress tar.bz2 files. Just be sure to check the man page (man tar) to learn more about the command.


Well, for better or worse, my articles have been pretty verbose lately. Yes, yes it does tell me how many words are in each article. I’m not sure why I ended up being more verbose lately, but I think it’s a good trend.

Anyhow, today we learn how to decompress tar.bz2 files in the Linux terminal. It’s a useful skill to have and a good tool to toss into your Linux toolkit. You never know when you’re going to need to use these commands, but there may come a time when you do – and you can refer back to this article to learn how.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Let’s Decompress A File (tar.gz) In The Terminal

Pretty much every Linux user has to look up how to decompress a file in the terminal. Ask them to do it by rote and they’ll balk, but it’s actually pretty easy. Heck, there are entire jokes and comic strips dedicated to it. The thing is, it’s actually pretty easy and this article is going to show you how.

The tool we’ll be using for this is called ‘tar’ and the man page helpfully describes it like this:

tar – an archiving utility

If one is curious, the .gz is for gzip. It’s both a file format and a compression utility. The .tar is a container for multiple files. Its name comes from tape archive, where one would store multiple compressed files in one file. Think of it as a container for .gz files, if that helps.

Today’s article is meant to be REALLY basic, so we’re only going to approach this with the tar command. The only goal of this article is to teach you how to decompress a .tar.gz from the terminal. (There are a dozen GUI ways to do this, but not all systems have a GUI available.)

Decompress A File:

This article requires an open terminal. You can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

You’ll also need a .tar.gz, but I’m going to assume you already have. If you don’t have one, you’re bound to reach that eventuality so long as you continue to use Linux. It’s a preferred file distribution format for things like source code. 

Anyhow, it’s really simple. Navigate to the folder where your .tar.gz file exists and run the following command:

You really only need to remember the vzf. In order, those stand for verbose (tells you what’s going on), z (decompress the files inside), and f (means the name of the file you’re working on).

The x flag means extract and we’ll get back to that in a moment.

You can even tell tar to extract the files in a specific directory. That’d look like this:

But, that’s not too terribly important, so long as you clean up after yourself and don’t leave a bunch of clutter. 

Let’s get back to that x flag. See, if you want to go the other way, that is to compress some files, you just change the x to a c.

In this case, we’re only to cover compressing all the files in a specific folder. That’s a little something like this:

So, really, you only need to remember the “vzf” and x for extract or c for compress. That’s the basics of decompressing a file in the terminal. There are a zillion possible combinations and the man page for tar is about a mile long.

In the vast majority of cases, those are the only two ways you’re going to use the command. If you need something more specific, check man tar.


And, there you have it. You have the very basics on how to decompress a file from the terminal. There’s a lot more to the tarball but we really don’t need to cover that. If you need more, there’s the manual – but you probably won’t need more than that.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.