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.

Closure:

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.

Open ‘WebP’ Images In Linux Mint

Today’s article shouldn’t be all that complicated, as we’re just going to touch on how to open WebP images in Linux Mint. I am not sure how many people this will help, but it seems like a good idea for an article. It’s also something I’ve recently dealt with, so it’s fresh in my memory. So, if you want to open WebP images in Linux Mint, read on!

Why Linux Mint? Well, because I know it works in Linux Mint. I just happened to be using one of my Linux Mint systems when I encountered this problem. I’m positive this works in other distros, but I’ve only tested this with Linux Mint.

The Story:

I wrote an article about how to disable window grouping in Lubuntu. A lovely friend pinged me to a question on AskUbuntu that involved this subject, suggesting that I answer it. I decided to answer the question.

Being lazy, I wanted to answer the question using the same screenshot I’d used in the article. I did the rational thing and downloaded the file from the linked page. 

The image had a border around it and I wanted to remove that border. I went to open the file with the WebP extension in my image viewer only to learn that there was no native support. When I opened the file, it showed the image in a new browser tab.

I could open the file in XnView and be done with it, but that wasn’t good enough. I wanted to be able to open the file natively, in my default image viewer. Alas, time was of the essence and I put that task aside so that I could answer the question. Later, I’d return to the problem and find a solution.

For reference, this is what it looked like when I tried to open a WebP file with the default image viewer:

there's no webp support
As you can see, that’s hardly a productive image.

It would happily show the image in the browser I had open because the WebP format is meant for the internet. That’s hardly useful and opening a browser to view an image just seemed like a step too far.

If you don’t know what WebP files are, you see and deal with them constantly – even if you don’t know, you can read the Wikipedia article about WebP files. They’re image files that are optimized for web use.

I wanted to find a way to open WebP images natively in Linux, specifically Linux Mint. My quest sent me down several false trails and I eventually found a solution that worked. This article shares that with you…

Open WebP Images In Linux Mint:

That’s right, there is a solution. To do this, which is open WebP images, we will need to have an open terminal. It’s okay, you only need it for a few commands. So open your terminal emulator. In many cases, you can just press CTRL + ALT + T.

With the first command, we’re going to add a repository:

Follow the directions and add the repository. Then you need to update the list of available software, like so:

Finally, install the following software with this command:

You don’t need to do anything else. That’s it. That is all you need to do. When you next open a WebP image in Linux Mint, you should be able to do so just fine with your default image viewer.

It should look something like this:

when you've completed these steps, you should be able to view WebP images in your default image viewer
See that image? That right there smells like success! It’s a WebP image!

If you click on that image, you can see that it’s a WebP image by looking at the title bar. The application should look familiar. It should look exactly like the default image viewer included with Linux Mint.

And now you know…

Closure:

That’s all there is to it. Linux is great like that. Sure, it took a bit of digging but there was a solution to my problem. Once I knew the correct solution, it was easy to implement. If you want to open WebP images in Linux Mint, you can do exactly that – without all that much effort. If you dream and work hard enough, someone else will have already done all the work and you can just use their software to accomplish your goals!

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.

Show Files Installed With A Package (Using ‘dpkg’)

Today’s article is going to be quick and easy, as we simply cover how to show files installed with a package. Because I am reasonably compelled to optimize for search engines, the title just plain sucks. It should be much longer. Even though the exercise is really simple, explaining what we’re doing is a bit more complicated.

NOTE: The ‘dpkg’ may confuse some folks, but it means this article is only valid for those folks who are using .deb files, the apt package manager, and nothing else. So, if you’re using Debian, Ubuntu, Mint, or similar, then this article is meant for you. If you’re using a different distro, maybe I’ll cover those in another article.

So, what exactly are we doing?

Well, when you install software you don’t generally install just a single file. At least not if the software is all that complicated. 

Instead, you install all sorts of other files along with the software you’re installing. You don’t just install a single binary file, you install quite a few other files along with it.

Today, we’re going to list the files, the dependencies if you will, that go along with the applications we install. It’s not difficult, just a single command, but you can see why this would make for a very long article title.

Let’s keep this article short, as I’ve done some longer material lately:

Show Files Installed With A Package:

Yeah, you’re going to need a terminal for this. If you want to use ‘dpkg’ then you will need an open terminal. As that’s what we’re using, we need said terminal. In most distros you can just press CTRL + ALT + T and your default terminal should open.

The tool we’re using is ‘dpkg’ and the man page describes it like this:

dpkg – package manager for Debian

The ‘Debian’ bit is important. As I mentioned above, this only works for distros that use dpkg to begin with. Anyhow, that’s an accurate description of what dpkg does.

The command we’ll use is simply:

For example, you might try:

If you have Chrome installed,  you might try this command:

As you can see from the output, you’re generally installing a bunch of files when you install a new application. It may not appear that way during the installation process, but you’re most likely installing more than a single file each time you install an application.

Closure:

If you’ve ever wanted to show files installed with an application, now you know. It’s a pretty handy command to have if you’re into that sort of thing. If you’re playing the game of the lightest-possible-distro, then maybe you want to keep the number of files installed to a minimum and use the lightest software you can. Either way, it’s an informative command that should amuse my readers for five to ten minutes.

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.

How To: Kill Processes By Their PID (Process ID)

Today’s article is one my regulars will be expecting, as it is an article that teaches you how to kill processes by their PID (Process ID). This shouldn’t be a long or complicated article and I’d like to think a beginner can understand what it is that we’ll be doing.

If you aren’t familiar with a process PID, you should read the article that I wrote just so that I could write this article:

Find An Application’s Process ID (PID)

Seriously, if you’re at all unsure, read that article. You could even consider that article the first part of this article, except I didn’t want to make my article long. Besides, it’s quite likely I’ll be referring to PIDs in the future.

NOTE: The subject we’ll be approaching today can be quite complicated. In this case, there are all sorts of ways to kill processes. Because of this, we’ll just be covering a couple of very easy ways to kill processes by using their PID. 

Why would you want to do this? 

Well, like it or not, sometimes applications freeze and sometimes applications refuse to close. This is true on every operating system. It can (and probably will) happen. I just tried a pinball application last night and it refused to close. (I closed it using the GUI task manager, not via the PID. Shh!)

Why would you want to kill processes by their PID, especially when you can also ‘killall‘ processes by their name?

Sometimes, you have processes with names like this:

Instead of trying to close that with a command, it has a PID of its own and can be closed using that. It’s so much easier to use the PID for this that you might as well learn how to do it now. Again, it won’t be all that complicated. I’ll do what I can to explain just a couple of choices while we all safely ignore the many other options.

NOTE: This isn’t quite the article I intended to write, so there’s that. The people on the Linux.org forum will know what I mean. This is largely due to my horrible memory.

Kill Processes By Their PID:

Yeah, this is a terminal thing. As such, you’re going to need an open terminal. In most distros, you can just press CTRL + ALT + T and that should be enough to open up your default terminal emulator.

With your terminal now open, let’s have a look at the tool we’ll be using:

If you won’t want to look, the kill command describes itself like this:

kill – send a signal to a process

Handily enough, that’s what we’ll be doing. We’ll be sending a single to a process, specifically to kill the process. You can send other signals. You can send quite a few different signals. Enter this into your terminal:

But, we’re only going to concern ourselves with 9 and 15. Those are the only two we’re going to worry about today. The syntax of the kill command would look like this:

Of course, you’re going to need to know the PID. If you read the article linked in the beginning section, you’d know how to do that. But…

For the sake of this article, we’ll be using ‘shutter‘, as it’s a fine application.

So, if you didn’t read the article about finding an application’s PID, helpfully linked again, we can just use ‘pgrep’. If I run the command on my computer, I get:

So we can now see the PID for Shutter easily enough. (There are numerous ways to get an application’s PID. The pgrep application is generally pretty handy.)

The first command we’re going to try is asking the application to quit. We’re sending a command to the application and asking it nicely to die. That’s -15.

Using the PID gathered in the previous command, and knowing the proper syntax for this command, we end up with a command that looks like this:

Of course, sometimes the application doesn’t die when asked nicely. That’s not all that often, but it’s also not all that rare. It does happen and that’s when we skip trying to talk to the application and send a command straight to the kernel. That’d look like this:

That command tells the kernel to drop the application. In theory, this always works. You may still see the process listed in your list of processes but that’s just a zombie process and nothing to be too alarmed with.

You want to first try -15 because that closes the application more gracefully.  When you use -9 as your signal, you’re more or less just using a hammer to kill the process. If -9 doesn’t work, something is up with your kernel and it’s time to reboot. 

NOTE: The commands I used did not include ‘sudo‘. That’s because I owned the processes. If it’s a process owned by someone other than your user, you will need the correct permissions to kill it, such as sudo.

I am not going to cover them here, but you can send all sorts of signals with the kill command – not all of which kill the process. For more information, I highly recommend the following command (and then digging deeper into the rabbit hole):

I suspect you’ll find that to be more than enough information for one day, even though this article hopefully makes it so simple that a beginner can follow along. Hopefully…

Closure:

Well, there you have it. Here’s yet another article and this time we’ve learned how to kill processes by their PID. There’s so much more to this, but those are the basics. You can generally ignore the rest as an average user. You can also probably do a great deal of this with the task manager, all with a nice GUI. It’s worth knowing, and doubly so if you spend any time remotely connected to another device via SSH.

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.

Find An Application’s Process ID (PID)

Today we’re going to have an article that’s straightforward and simple and it will be about how you find an applications’s process ID (PID). This isn’t the article I want to write. This is a case where I have to write one article so that I can write another article. Otherwise, we’d end up with a two-thousand-word article that nobody would read. 

Let’s start with the basics – and it is very, very basic…

Every process running on your Linux computer has a Process ID (PID from here on out). Each process has a unique PID. Curiously, not all PIDs are using resources. Some PIDs are sleeping. If you work at it and find the right dodgy application (I’m looking at you, Shutter), you can even find zombie processes that are darned near impossible to kill (which might be foreshadowing a future article).

Though, unlike the movies, zombie processes are perfectly okay. They just sit there consuming no resources. Plus, they don’t eat brains (or CPU power), nor do they devour human flesh. They don’t even spread to other processes. In fact, with all that information, maybe calling them zombie processes is a bad idea. It’s not my idea – and they do share one thing in common with zombies in that they can’t be killed. (Zombies are already dead. You can’t kill something that’s already dead!)

There are many ways to find the PID for any given process. You can probably crack open your system monitor and find quite a few listed right there. You won’t even need the terminal for that. Imagine that?!?

(Of course, we’ll be finding PIDs in the terminal. It’s just what we do.)

Find An Application’s PID:

Yup. We’ll need an open terminal. Chances are reasonably good that you can just press CTRL + ALT + T and open up a terminal. Give it a shot, if you haven’t already.

The first thing we’re going to do is generate a giant list of running processes. The first column will be who owns the process (not always you) and the second column will be the PID. To generate this giant list, try this command in said terminal:

It’s a pretty big list, isn’t it? Well, let’s use ‘grep’ to narrow that down quite a bit. You can pipe the output from the previous command into grep and that would look like this:

Using Shutter as an example, the command would look like this:

NOTE: You may find that you see multiple PIDs. That’s because there are multiple instances of the application running. 

If you know the name of the process, you can also try pidof (which should also indicate what it does – it tells you the PID of an application).

So, let’s say we wanted to know the PID of bash. That command would look like this:

In my case, I get four different numbers because I have multiple terminals open, each using bash. No, I don’t consider four open terminals to be abnormal. Well, at least it’s fairly normal for me.

Finally, chances are pretty good that you have ‘pgrep’ available. I did a flip through some VMs and it appears to be installed by default on all the distros I checked. You can use pgrep to find a PID. That would look like this:

So, using Shutter as an example again, we’d try something like this:

Now, not all processes seem to want to be listed like this. For example, if you run the ps aux command, you might have seen processes with weird names like this:

You go ahead and put that into pgrep and let me know if it works for you! It doesn’t work here. But, if you tried pgrep gvfs it will spit out some PIDs for you. At that point, you’re officially above my pay grade. I am not sure and I do not know everything. I did some searching, like a good 30 minutes worth of searching, and didn’t find anything conclusive.

If you happen to know what’s going on, let me know in the comments! Someone is always happy to let me know what I missed (and I’m so grateful for that, I really am.) I swear, I learn more from writing these silly things than you learn from reading them.

Closure:

Well, have you ever needed to know the PID? It’s a pretty useful thing to know, which I’ll cover in a future article. I didn’t want to write some giant 2000-word article only to have folks gloss over the important bits. Sure, it’d make a nice segue to the next article, but you know darned well that I’m unlikely to write the articles in order. I get bored easily!

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.

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.