facebook youtube pinterest twitter reddit whatsapp instagram

Dealing With Misbehaving Processes in Ubuntu

If you are used to the Windows system, you would have likely come across a misbehaving application, which can most likely be killed using the Task Manager.

This is similar in GNU/Linux, the only difference is that you have to do it over the terminal, so, how do we deal with misbehaving processes on our GNU/Linux server?

If a process refuses to close normally or misbehaving, you may need to kill the process using the kill or killall commands. To get started with this, you first need to figure out the PID of the process, PID is a number assigned to a given process on your system, while humans can easily reference a process by name (e.g bash), the system knows processes by their ID, so, each program you open is given a different PID.

Go ahead and type the ps command in your console:


I'll assume the PID 321 is behaving, so, to kill it, I'll execute:

sudo kill 321

Bam! The process should most likely end now, so, you could check the logs for more information as to why it was misbehaving in the first place, and restart.

The way the kill command works is telling the process to cleanly terminate, if successful the process will free its memory and gracefully shuts down. Gracefully shut down means the process is given time to save its progress (the current works its doing), and the release resources (free its memory), in a simple sentence, it is not forced to stop.

If for some reason you aren't able to close a process, then you would have to force stop it, this is considered an extreme last resort and should be used with caution.

To force stop a process, you will send signal 9 to the process, this will force-closed the process without giving it any time to save its progress or react at all.

Note: By Default, the kill command sends signal 15, you can learn more about the GNU/Linux signal by consulting the man page: man 7 signal

So, to force-close PID 321, I'll use:

sudo kill -9 321

This will immediately kill the process without gracefulness, if for some weird reason, the process still manages to stay running, then try to reboot the server.

What if you want to kill a process by name?

Fortunately, you can! By using the killall command, you can kill any process by name, but note that it kills any process it finds with the name you've given as an option.

For example, let's say I want to kill all nano editor:

sudo killall nano

You can also send signal 9 to force stop the process as well:

sudo killall -9 nano

Related Post(s)

  • Monitoring Multiple Log Files In RealTime With MultiTail (Ubuntu)

    Oh my... I really find scanning through the logs file time consuming, and painful. Luckily for me, I founded Multitail, which is an awesome, and powerful tool for not only browsing through several f

  • How To Find Files Using Locate in Ubuntu

    It's kind of frustrating when you are searching for a particular file, and you have no idea of how to find it, In this guide, I'll walk you through on two different ways you can find a file in your G

  • Managing MariaDB Databases (Ubuntu Server)

    In this guide, you'll learn how to manage MariaDB databases in your terminal, from connecting to the database server using the mariadb command, creating a database, removing (drop) database, and mana

  • Viewing Disk Usage in Ubuntu

    There are several ways to view disk usage in your Linux system, and that is what we would be going over in this guide... Out of the box, Linux provides us the df command, which is the standard Unix c

  • Understanding & Using Symbolic & Hard Links (Ubuntu)

    Have you ever wondered how you can create shortcuts that link to other files in Linux? Well, let me introduce you to symbolic and hard links. The two types of links in Linux are symbolic links and ha

  • Installing and Using dig in Ubuntu

    dig is an awesome utility for querying DNS name servers. It performs DNS lookups and displays the answers that are returned from the name server(s) that were queried. In this guide, you'll learn how