Find and Kill a Process in Linux — ps, kill, pkill

16 Mar 2026 By Olga Naumova

To end a process in Linux, first find its PID (identifier) with ps or pgrep, then send it a signal with kill. To finish a process by name, pkill and killall are handy. Let’s take it step by step.

Step 1. Find the process

Show all processes and filter by name with grep:

ps aux | grep nginx

In the output the second column is the PID. A more direct way is pgrep, which returns the identifiers straight away:

pgrep -a nginx

The -a flag shows the PID together with the command line.

If the process is holding a network port, find it by that port:

sudo ss -ltnp | grep :80

Step 2. End the process by PID

The standard command is kill. By default it sends the TERM signal (15) — a polite request to shut down that lets the process save its data:

kill 12345

If the process does not react, send the KILL signal (9) — a forced termination with no chance to save anything:

kill -9 12345

Always try a plain kill first, and only use -9 if the process is stuck.

Ending a process by name: pkill and killall

You do not have to look up the PID — you can end a process by name.

pkill matches part of the name:

pkill nginx
pkill -9 nginx

killall ends every process with an exact name:

killall nginx

Be careful: pkill php ends every process whose name contains php.

Killing from htop

The visual way is through htop:

htop

Find the process (press F3 to search), select it with the arrow keys and press F9. Choose the signal (usually SIGTERM, then SIGKILL) and confirm.

The main signals

Signal Number Action
SIGTERM 15 Graceful shutdown (default)
SIGKILL 9 Forced termination
SIGHUP 1 Reload config / restart
SIGINT 2 Interrupt (like Ctrl+C)

Reloading a service configuration without stopping it is often done like this:

kill -HUP 12345

Finding the process that loads the system

To find the hungriest process by CPU:

ps aux --sort=-%cpu | head

By memory:

ps aux --sort=-%mem | head

Frequently asked questions

How does kill -15 differ from kill -9? -15 (TERM) asks the process to shut down properly: close files, save data. -9 (KILL) kills it instantly and it saves nothing. Start with -15.

The process will not die even with -9. What now? That happens with processes in state D (uninterruptible sleep, usually waiting on disk). They cannot be killed until the I/O operation finishes; sometimes only a reboot helps.

How do I end a process when I only know the port? Find the PID with sudo ss -ltnp | grep :PORT, then run kill PID. Or do it in one command: sudo fuser -k 80/tcp.

Is killall dangerous? It ends every process with the given name. Check the list first with pgrep -a name so you do not stop more than you meant to.

Summary

ps/pgrep for finding and kill/pkill for ending cover almost every process management task. The rule is simple: a gentle TERM first, and KILL only for the ones that hang.

Managing your own server? Take a Linux VPS, order VPS hosting, or order Server administration if you would rather leave monitoring to specialists.

Olga Naumova