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.

How To: Remove A Package With YUM

Today’s article is pretty basic, as the title so helpfully implies, as it simply tells you how to remove a package with YUM. I am writing this article because of a comment sent to me via the contact page. The gist of the comment is that I seldom include information about YUM but lots of information about APT.

I welcome such. If I didn’t, I wouldn’t have the option to contact me! In a similar vein, if I didn’t welcome comments WordPress would happily allow me to disable said comments. I welcome all that sort of stuff, even including the comments I get elsewhere. For the record, some of those comments are so good that they’d be welcomed additions to the articles themselves. Alas, so few people seem inclined to do so and their helpful additions are lost to the aether.

Anyhow, back to the comment sent via the contact page…

The person sending me the message is correct. It’s true. More often than not, I only include information about APT. In my defense, other than servers or playing around in virtual machines, APT is my usual weapon of choice. I’m familiar with it, indeed comfortable with it. As such, my brain just kinda defaults to it.

So, what is YUM? Well, YUM is like APT for people using RHEL, CentOS, Fedora, Rocky, and quite a few other choices, might I say professional, operating systems. While the numbers I can find indicate the APT-using distros dominate the desktop market, it’s almost certain that the server market is dominated by people using a distro with YUM as the package manager.

YUM stands for Yellowdog Updater, Modified. It is the package manager for distros using the RPM (Red Hat Package Manager) formatted, or standardized, packages. It is very old and very stable. Those are not bad things, especially in the server and professional markets – where things like stability are prized. If you used YUM back in the day, I have good news for you. It hasn’t changed! Well, not significantly, as Wikipedia happily tells me that the last stable version was about eleven years ago at the time of this writing. Again, that is not a bad thing! I can’t stress that enough.

Because I don’t cover YUM enough, I figure a nice introductory article will be good. It’ll be a good thing to expose folks to YUM when they’re mostly just familiar with APT. As such, I figure some basic commands are a good place to start. 

So, let’s get to it…

Remove A Package With YUM:

Of course, you use YUM in the terminal. That means you’ll need to have an open terminal. In most distros, you can just press CTRL + ALT + T and your default terminal should open. If this doesn’t open your terminal, you can almost certainly find a quick and easy way to modify your keybindings.

With your terminal now open, the process is pretty simple to remove a package with YUM. The command would look something like this:

You can also use the following format:

Those commands will only remove the package you named. So, if you removed a program like Thunderbird, your configuration files and any dependencies will (should) remain on the system. This is useful for when you need to reinstall an application but want to try keeping your existing configuration.

If you want to also remove your configuration files and any dependencies, YUM will happily allow you to do that. To do so, that is to remove the application, any configuration files, and dependencies, you’d try a command like this:

While it may look similar, it functions differently than autoremove functions in distros like Ubuntu. So, the syntax may look similar, but there are differences between the commands and it may be prudent to remember that. After all, the goal is to remove a package with YUM and not APT.

If you want to get fancy, you can add the following to your /etc/yum.conf to make sure that when you remove a package with YUM it will automatically remove the dependencies and configuration files:

However, adding that command will mean you do exactly what I said you’d do if you did that. You will also remove your configuration files and any of the application’s dependencies. If you’re sure that’s what you always want to do, you can do it! Ain’t Linux awesome?!?

Closure:

Well, I wanted to write an article about YUM for our RHEL-using peers. I didn’t want it to be too basic, so I figured I’d add a little more to it. The reality is that I don’t cover other distros that often but, in my defense, this is largely aimed at making Linux approachable – or, as the tagline says, “Getting you up to speed.” Most of my readers are going to be using distros with APT and much of my content is generic enough to apply to any major Linux distro.

So, there’s that… If you want to see even more of this type of content, leave a comment (here, preferably) to let me know. I ain’t scared! If this is the type of content that suits you, that’s great and I can write more of it. It’s not hard to include the commands for other distros, it’s just time-consuming.

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 Play Around With The Linux Shell.

Today’s article is a bit of a mystery, as I’m writing it and not sure how it’s going to end up – but it will be about the Linux shell. I’ll try to make it approachable, even for beginners. Let’s see where the article takes us!

I think I’d caution most beginners to stick with what came with their distro (most likely Bash), rather than straying into the world of different shells. Wait until you have a few more miles in your Linux shoes before running to try new shells. It’ll make support easier if you don’t have to compound things by using an alternative shell. Once you’re up to speed, there are some nifty choices.

This seemed like the perfect question to pose ChatGPT. I’ve found a way to make AI useful – or so it seems to me. I asked the AI to explain the Linux shell in two paragraphs. This is what they had to say:

A Linux shell is a command-line interface (CLI) program that allows users to interact with the Linux operating system by entering commands. It acts as an intermediary between the user and the kernel, which is the core of the operating system. The shell provides a text-based environment where users can execute various commands to perform tasks such as navigating the file system, running programs, managing processes, and configuring system settings.

The shell interprets the commands entered by the user and translates them into instructions that the kernel can understand and execute. It also provides features like command completion, history, and scripting capabilities, allowing users to automate tasks and create powerful scripts. There are different types of shells available in Linux, such as Bash (Bourne Again SHell), which is the default and most widely used shell in Linux distributions. Other popular shells include Zsh (Z Shell), Ksh (Korn Shell), and Csh (C Shell), each offering its own set of features and functionalities. Overall, the Linux shell is a fundamental component of the operating system, providing users with a flexible and efficient way to interact with the system.

That looks like a pretty good description to me. If you have any questions, you can certainly leave a comment. You know where to find me so that you can ask questions most anywhere.

Hmm… As I said, I’m not sure where this article is headed. We’ll have to see…

Some Stuff About The Linux Shell:

Pretty much every single one of the new folks reading this will have something in common with those who have used Linux for years. You’re almost certainly using Bash as your shell. Bash stands for Bourne Again Shell. Bash is the Linux equivalent of Bourne Shell that came with Unix back in ye olden days.

If you want, you can open a terminal at this point. Odds are that you have another shell or two available. You can list your shells with the following command:

If you don’t already know what shell you’re using, you can find out quickly enough. Just run this command to find out which shell you’re using:

Let’s pretend you’re using Ubuntu and want to install a new shell. Let’s pretend you are interested in ZSH. That is ‘Z Shell’ and is an alternative that you might consider. The first step would be to install ZSH and you’d do so like this:

Follow the prompts and when you next run cat /etc/shells again, you’ll see that ZSH is an option. Pay attention to the path. It will look like /usr/bin/zsh and you can change to that shell quickly enough. Just run the following command:

Or, for a better example:

You’ll then want to reboot your system. That’s easily done with:

That should do the trick for pretty much everyone, though you’ll need to use your package manager if you’re not using apt with Debian, Ubuntu, Mate, or similar. It’s easy enough to switch to a new Linux shell – but you should probably have a good reason for doing so.

By the way, feel free to leave a comment if you use a different shell, preferably explaining why you’ve chosen to do so. I’ve played with different shells and that was entirely my reason for doing so, I just wanted to play around with them. I stick with Bash pretty much exclusively, or whatever’s installed by default.

Again, I’d caution you newer users to skip this article and just use this pile of words to learn about shells in the first place. If you’ve been using Linux for a while and want to learn something new (or have a specific reason to do so) then you can change your shell as much as you’d like. It’s your computer, you can do anything you darned well want with it!

Closure:

So, I wasn’t sure what this article was going to look like. I just figured I’d do an article about the Linux shell. We all know at least one beginner is going to start mucking about with alternative shells, at least this way we can tell them that we suggested they wait to do so.

Then again, how often did we wait to do so? How often did we go mucking around with things best left untouched until we learned better? At the end of the day, Linux is an OS that suits those who like to tinker, but she can be a harsh mistress when you’re still learning. And, again, how many of us learned by breaking things? I reckon many of us did and that’s how we got here.

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: Find Out Which Window Manager You’re Using

Today’s article shouldn’t be all that long or difficult, as we simply go over how to find out which window manager you’re using. In the Linux world, this is often abbreviated as “WM” but we’ll avoid using the abbreviation ’cause of search engines. Yeah, search engines have a lot to do with how this (and every other) site is configured – including deciding how I write articles.

Yay! We need to appeal to you AND the algorithms. We’re all slaves to the machine! 

So, what is a window manager? We can cheat and cite the Arch Wiki (a brilliant source for all things Linux). They define window managers as:

A window manager (WM) is system software that controls the placement and appearance of windows within a windowing system in a graphical user interface (GUI). It can be part of a desktop environment (DE) or be used standalone.

Further, there are the following clues:

Window managers are X clients that control the appearance and behaviour of the frames (“windows”) where the various graphical applications are drawn. They determine the border, title bar, size, and ability to resize windows, and often provide other functionality such as reserved areas for sticking dockapps like Window Maker, or the ability to tab windows like Fluxbox. Some window managers are even bundled with simple utilities like menus to start programs or to configure the window manager itself.

Now, in modern times, most of you will be using the window manager that came with your distro and you’ll just leave it as the default. This article is for that person – the person who didn’t install their window manager and doesn’t know which window manager they’re using.

Which Display Manager Are You Using:

You guessed it! You’re going to need to use a terminal for this. Oh, there are surely GUI ways to do this, but I know you have a terminal. You can just press CTRL + ALT + T to open your default terminal.

With your terminal, you can run the following command:

If that command doesn’t spit out the information you’re after, you may need to install it. Your trusty default terminal should happily tell you how to install wmctrl, but it’d be (in Debian/Ubuntu/Mint/etc) something like this:

Of course, if you have Neofetch installed, you can just run Neofetch. Like ‘wmctrl’, you might need to install it. You might as well install it, though you could just as easily use Screenfetch. You get to pick which one you want to use, but it’ll be listed under the aforementioned abbreviation of “WM”. See? Foreshadowing! I can’t believe you read this nonsense.

So, there are a few options to find out which window manager you’re using. You can pick which you like most, but either of the *fetch applications will give you more system information. Do what you must…

Closure:

I planned on another article, but this one seemed like a more interesting article to write today. As it seemed more interesting to share how to find which window manager you’re using, I decided to go with that one.

These “easier” articles take about the same amount of time to write. The subject is often decided by what I feel is the most interesting. You can always start your own site and write along with me. There’s room for all of us!

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.

Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.