Kill a Process in Linux
Finding and Killing Processes
The pkill command can be used to stop / kill all processes that match its pattern from the command line:
pkill -aif warp
If you want to be more precise, the kill command can be used to quit a particular process by specifying its process ID:
kill 2934
There are a number of ways you can discover the IDs of running processes depending on what you know about the process.
Searching For The Right Process To Kill
You can search for a process by:
- The command name that was executed to spawn it:
pgrep -aifl firefox
- The user that executed it:
pgrep -u root
- A network port it's using:
lsof -i tcp:8888
- A file it has open:
lsof /dev/null
Force Killing Processes
If the process doesn't end, you can force kill the process by sending it the SIGKILL signal. To do this, simply add the -9 argument to kill or pkill:
pkill -9 -aif firefox
pkill and pgrep vs. killall and ps
killall and ps are the old-fashioned equivalents of pkill and pgrep. They're now generally discouraged because they behave very differently and are somewhat hard to use. Some versions of Linux may not even provide killall.
If you still want to use killall, you might have difficulty targeting the right process, but you can try the following:
killall Firefox
💡Tip for Warp Users
If these commands don't find any matching processes, they will often silently exit with no notice that it didn't work other than a nonzero return code. Warp users will notice that the terminal block is helpfully made red to indicate that the process failed.

Process Signals
By default, running kill or pkill sends the SIGTERM signal to the specified process, which is the polite way to ask the process to terminate. The process can choose to ignore or handle this signal rather than ending, either purposefully or because the process is misbehaving.
Signals you can send include:
- 2 - SIGINT - Interrupt the program (equivalent to pressing Ctrl+C on the terminal)
- 9 - SIGKILL - Forcibly terminate the program immediately (cannot be ignored or handled)
- 15 - SIGTERM (default) - Request that the program terminate (can be ignored or handled)
Command Portability
Some of these commands and their flags may behave slightly differently on different operating systems. Favoring pkill (instead of killall) and pgrep (instead of ps) can help reduce these issues. All of the specific invocations listed above will work on both Linux and MacOS.
Related articles
Bash Comments
Comments will help make your scripts more readable
Reading User Input
Via command line arguments and prompting users for input
Curl Post Request
Use cURL to send data to a server
Upload Files With curl
Learn how to upload a file to FTP, SFTP servers, Artifactory, and AWS S3 using the curl command.
How To Copy A Directory In Linux
Learn how to copy directories and their content in Linux using the cp command with options like -r for recursive copying, -i for interactive mode, and -a for preserving attributes.
Create Groups In Linux
Learn how to manually and automatically create and list groups in Linux.
How to Check the Size of Folders in Linux
Learn how to output the size of directories and subdirectories in a human-readable format in Linux and macOS using the du command.
Count Files in Linux
Learn how to count files and folders contained in directories and subdirectories in Linux using the ls, find, and wc commands.
List Open Ports in Linux
Learn how to output the list of open TCP and UDP ports in Linux, as well as their IP addresses and ports using the netstat command.
Format Command Output In Linux
Learn how to filter and format the content of files and the output of commands in Linux using the awk command.
Create Directories Recursively With mkdir
Learn how to recursively create nested directories using the mkdir command, Bash scripts, and Python scripts.
Remover Users in Linux
Learn how to remove local and remote user accounts and associated groups and files in Linux using the userdel and deluser commands.