Wednesday, March 29, 2023
  • Events
  • Interviews
  • Jobs
  • Opinion
  • Whitepapers
  • Podcasts
  • Web Hosting Directory
  • Login
  • Register
Cloud7 News
  • Cloud Computing
  • Web Hosting
  • Data Center
  • Linux
  • Cybersecurity
  • More
    • Software
    • Network/Internet
    • Hardware
    • Artificial Intelligence
    • Windows
    • Policy/Legislation
    • Blockchain
    • Troubleshooting
    • How-Tos
    • Articles
No Result
View All Result
Cloud7 News
  • Cloud Computing
  • Web Hosting
  • Data Center
  • Linux
  • Cybersecurity
  • More
    • Software
    • Network/Internet
    • Hardware
    • Artificial Intelligence
    • Windows
    • Policy/Legislation
    • Blockchain
    • Troubleshooting
    • How-Tos
    • Articles
No Result
View All Result
Cloud7 News
No Result
View All Result

Home > How-Tos > How to kill a process in Linux?

How to kill a process in Linux?

Killing a process may seem complicated for Linux beginners. In reality, it's effortless. This tutorial explains how to kill a running process on Terminal on Linux.


Ugur Kubilay Cam Ugur Kubilay Cam
September 27, 2021
3 min read
How to kill a process in Linux

To kill a running process, you must find out the process id or process name on the Linux console (Terminal). As an example we will find and kill the mysql service.

Table of Contents

  • Step 1: View and locate the running process
    • “top” interface
    • “ps” command
    • “pgrep” command
    • “pidof” command
  • Step 2: Killing process
    • “kill” command
    • “killall” command
    • “pkill” command
    • “kill -9” command
    • “xkill” command
    • “top” interface

Step 1: View and locate the running process

“top” interface

The top command is used for real-time monitoring of running processes on Unix and Linux operating systems.

Usage:

[email protected]:~$ top

or you can use it with the grep command to search for a specific process.

[email protected]:~$ top | grep mysql

Output:

"top" command in linux terminal


“ps” command

The “ps” command lists the processes currently running in the operating system. If you want the running processes to be displayed in real time, you can use the top command. The ps command can take with it three commonly used parameters a, u, and x. This command shows all running processes and process owners in the system and terminals.

Usage:

[email protected]:~$ ps aux

or you can use it with the grep command to search for a specific process.

[email protected]:~$ ps aux | grep mysql

Output:
ps aux command in linux terminal


“pgrep” command

“pgrep” is a command firstly written for the Solaris 7 operating system. It was later refactored for Unix and different BSDs. It prints the ID of the named processes.

Usage:

[email protected]:~$ pgrep mysql

Output:
pgrep command in linux terminal


“pidof” command

Pidof is an application that returns the IDs of running processes like pgrep.

Usage:

[email protected]:~$ pidof <process Name>

Sample:

[email protected]:~$ pidof mysql

Output:
pidof command in linux terminal

 


We have obtained the ID (1111) and process name (mysql, mysqld) of the Mysql service, now let’s see how to kill/terminate this process.


Step 2: Killing process

On Linux, you can kill a process using the killall, pkill, kill, kill -9, xkill and top commands. Let’s see how to kill a process using these commands in Linux terminal.

“kill” command

“kill” is a command to stop processes running on Unix and Linux by signaling them.

Usage:

[email protected]:~$ kill <Process ID>

Sample:

[email protected]:~$ kill 1111
[email protected]:~$ _

“killall” command

killall is a command to kill the processes named.

Usage:

[email protected]:~$ killall <Process Name>

Sample:

[email protected]:~$ killall mysqld
[email protected]:~$ _

“pkill” command

“pkill” is a command that was also developed for the Solaris 7 operating system and is used to kill running processes by sending signals such as kill and killall commands.

Usage:

[email protected]:~$ pkill <Process Name>

Example:

[email protected]:~$ pkill mysqld
[email protected]:~$ _

“kill -9” command

Unlike the kill command, the kill -9 command is often used to definitively kill unresponsive processes. The kill command signals gracefully, while the kill -9 command is more vulgar at killing processes. Alternatively, it can be run with the -SIGKILL parameter instead of -9.

Usage:

[email protected]:~$ kill -9 <Process ID>

or

[email protected]:~$ kill -SIGKILL <Process ID>

Sample:

[email protected]:~$ kill -9 1111
[email protected]:~$ _

or

[email protected]:~$ kill -SIGKILL 1111
[email protected]:~$ _

“xkill” command

xkill is often used to force-kill GUI applications. It is quite useful in killing some unresponsive applications that cause the system to work abnormally.

Usage:

[email protected]:~$ xkill <Process ID>

Sample:

[email protected]:~$ xkill 1111
[email protected]:~$ _

“top” interface

You can kill running processes using the “Top” interface. Press the “k” key while running the “top” interface, enter the process ID and press “enter”.

Usage:

[email protected]:~$ top

Sample:

kill process using top interface linux

Ugur Kubilay Cam

Ugur Kubilay Cam

Ugur Kubilay Cam is the content marketing specialist of Cloud7 News. In addition to being an SEO expert, Ugur Kubilay is a Python developer and cybersecurity researcher. Ugur has a Bachelor's degree and a master's degree in Data Analysis. With more than 15 years of experience, Ugur Kubilay Cam is an active Linux user and administrator.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

I agree to the Terms & Conditions and Privacy Policy.

Next Post
Data center market to reach $517.17 billion by 2030

Global data center market to reach $517.17 billion by 2030

Related News

How to install and run Android apps on Windows

How to install and run Android apps on Windows

March 28, 2023 5:00 pm
Trisquel GNU/Linux 11.0 released, download now

Trisquel GNU/Linux 11.0 released, download now

March 28, 2023 10:20 am
What is a Daemon in Linux?

What is a Daemon in Linux?

March 27, 2023 8:01 pm
7 best practices and tools to use for Linux security

7 best practices and tools to use for Linux security

March 24, 2023 5:00 pm
Get free daily newsletters from Cloud7 News Get the Cloud7 Newsletter
Select list(s):

Check your inbox or spam folder to confirm your subscription.

By subscribing, you agree to our
Copyright Policy and Privacy Policy

Get the free newsletter

Subscribe to receive the latest IT business updates straight to your inbox.

Select list(s):

Check your inbox or spam folder to confirm your subscription.

Recent News

  • What is Nvidia Canvas? Everything you need to know
  • How to install and run Android apps on Windows
  • A new storage and optic communication tech is on the way
  • Interview: Pete Morgan, co-founder and CSO of Phylum
  • Trisquel GNU/Linux 11.0 released, download now

Cloud7 News
Cloud7 is a news source that publishes the latest news, reviews, comparisons, opinions, and exclusive interviews to help tech users of high-experience levels in the IT industry.

EXPLORE

  • Web Hosting
  • Cloud Computing
  • Data Center
  • Cybersecurity
  • Linux
  • Network/Internet
  • Software
  • Hardware
  • Artificial Intelligence
  • How-Tos
  • Troubleshooting

RESOURCES

  • Events
  • Interviews
  • Jobs
  • Opinion
  • Whitepapers
  • Podcasts
  • Web Hosting Directory

Get the Cloud7 Newsletter

Get FREE daily newsletters from Cloud7 delivering the latest news and reviews.

  • About Us
  • Privacy & Policy
  • Copyright Policy
  • Contact

© 2023, Cloud7 News. All rights reserved.

No Result
View All Result
  • Cloud Computing
  • Web Hosting
  • Data Center
  • Linux
  • Cybersecurity
  • More
    • Software
    • Network/Internet
    • Hardware
    • Artificial Intelligence
    • Windows
    • Policy/Legislation
    • Blockchain
    • Troubleshooting
    • How-Tos
    • Articles
  • Events
  • Interviews
  • Jobs
  • Opinion
  • Whitepapers
  • Podcasts
  • Web Hosting Directory

© 2023, Cloud7 News. All rights reserved.

Welcome Back!

Sign In with Facebook
Sign In with Google
Sign In with Linked In
OR

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Sign Up with Facebook
Sign Up with Google
Sign Up with Linked In
OR

Fill the forms below to register

*By registering into our website, you agree to the Terms & Conditions and Privacy Policy.
All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In

Add New Playlist

This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.