{"id":15849,"date":"2019-03-06T14:08:55","date_gmt":"2019-03-06T14:08:55","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=15849"},"modified":"2026-03-10T10:12:58","modified_gmt":"2026-03-10T10:12:58","slug":"how-to-kill-a-process-in-linux","status":"publish","type":"post","link":"\/uk\/tutorials\/how-to-kill-a-process-in-linux","title":{"rendered":"How to kill a process in Linux from the command line"},"content":{"rendered":"<p>In Linux, managing running processes can help maintain system health and performance. Sometimes, you might need to terminate a process to free up system resources or address unresponsive applications.<\/p><p>This practice, known as <strong>killing processes<\/strong>, ensures your system runs smoothly without unnecessary interruptions or resource drains. However, improperly stopping processes can lead to data loss or system instability.<\/p><p>In this article, you&rsquo;ll learn various commands to safely end processes in Linux, such as <strong>kill<\/strong>, <strong>pkill<\/strong>, and <strong>killall<\/strong>. By the end, you&rsquo;ll know how to manage and kill processes in a controlled manner effectively, ensuring optimal performance for your Linux machine.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Linux-Commands-Cheat-Sheet.pdf\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" width=\"1024\" height=\"283\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet-1024x283.png\" alt=\"\" class=\"wp-image-69262\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet-1536x425.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet-300x83.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet-150x41.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet-768x212.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-prerequisites\">Prerequisites<\/h2><p>Before learning how to kill a process in Linux, make sure to follow these prerequisites:<\/p><ul class=\"wp-block-list\">\n<li><strong>Linux-based machine<\/strong>. You need a computer or a server running a Linux distribution. If you don&rsquo;t have one, consider <a href=\"\/uk\/vps\/linux-hosting\">purchasing a Linux-based VPS from Hostinger<\/a>.<\/li>\n\n\n\n<li><strong>Terminal or SSH access<\/strong>. Open a terminal on your local machine or use an SSH application like<a href=\"\/uk\/tutorials\/how-to-use-putty-ssh\"> PuTTY<\/a> to connect to your Linux server remotely.<\/li>\n\n\n\n<li><strong>Root access or appropriate permissions<\/strong>. Most commands to kill processes require root or superuser privileges. Ensure you have the necessary permissions to execute them.<\/li>\n\n\n\n<li><strong>Installed tools<\/strong>. Make sure to install the required tools and commands on your system. To verify, run either of the following:<\/li>\n<\/ul><pre class=\"wp-block-preformatted\">sudo apt-get install procps x11-utils&nbsp; # for Debian-based distributions<\/pre><pre class=\"wp-block-preformatted\">sudo yum install procps-ng xorg-x11-apps&nbsp; # for Red Hat-based distributions<\/pre><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a href=\"\/uk\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner-1024x300.png\" alt=\"\" class=\"wp-image-77934\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/02\/VPS-hosting-banner.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/02\/VPS-hosting-banner-300x88.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/02\/VPS-hosting-banner-150x44.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/02\/VPS-hosting-banner-768x225.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-how-to-locate-a-process-in-linux\">How to locate a process in Linux<\/h2><p>You must first locate the correct process to avoid accidentally stopping essential system operations. Here are several commands to find details of <a href=\"\/uk\/tutorials\/vps\/how-to-manage-processes-in-linux-using-command-line\">running processes in Linux<\/a>:<\/p><p><strong>Locate a process with ps<\/strong><\/p><p>The <strong>ps<\/strong> command provides a complete listing of running processes and their details, such as the user, process ID (PID), CPU and memory usage, and the command that started the process.<\/p><p>Here&rsquo;s its basic syntax:<\/p><pre class=\"wp-block-preformatted\">ps [options]<\/pre><p>You can append these options to this command:<\/p><ul class=\"wp-block-list\">\n<li><strong>-a<\/strong> &ndash; display information about all users.<\/li>\n\n\n\n<li><strong>-u<\/strong> &ndash; include user-oriented output.<\/li>\n\n\n\n<li><strong>-x<\/strong> &ndash; show processes without a controlling terminal.<\/li>\n<\/ul><p>For example, if you execute the following:<\/p><pre class=\"wp-block-preformatted\">ps -aux<\/pre><p>You should see an output similar to:<\/p><pre class=\"wp-block-preformatted\">USER &nbsp; &nbsp; &nbsp; PID %CPU %MEM&nbsp; &nbsp; VSZ &nbsp; RSS TTY&nbsp; &nbsp; &nbsp; STAT START &nbsp; TIME COMMAND<br><br>root &nbsp; &nbsp; &nbsp; &nbsp; 1&nbsp; 0.0&nbsp; 0.1 169364&nbsp; 8824 ?&nbsp; &nbsp; &nbsp; &nbsp; Ss &nbsp; Jul08 &nbsp; 0:05 \/sbin\/init<br><br>root &nbsp; &nbsp; &nbsp; &nbsp; 2&nbsp; 0.0&nbsp; 0.0&nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 ?&nbsp; &nbsp; &nbsp; &nbsp; S&nbsp; &nbsp; Jul08 &nbsp; 0:00 [kthreadd]<br><br>...<\/pre><p><strong>Find PID with pidof<\/strong><\/p><p>The <strong>pidof<\/strong> command finds the process&rsquo;s PID by name. It&rsquo;s simple and handy when you already know the exact process name.<\/p><pre class=\"wp-block-preformatted\">pidof [options] [program]<\/pre><p>Some helpful options for <strong>pidof<\/strong> include:<\/p><ul class=\"wp-block-list\">\n<li><strong>-c<\/strong> &ndash; return only the same root directory processes.<\/li>\n\n\n\n<li><strong>-o<\/strong> &ndash; omit specified PIDs.<\/li>\n\n\n\n<li><strong>-s<\/strong> &ndash; single shot (this will return the first PID).<\/li>\n\n\n\n<li><strong>-x<\/strong> &ndash; scripts also (this will return processes that scripts have started).<\/li>\n<\/ul><p>For instance, to get the PID of <strong>sshd<\/strong>, run:<\/p><pre class=\"wp-block-preformatted\">pidof sshd<\/pre><p>If there is only one instance running, the output will be a single PID:<\/p><pre class=\"wp-block-preformatted\">1234<\/pre><p>However, if more than one instance is running, it will display multiple PIDs:<\/p><pre class=\"wp-block-preformatted\">1234 5678<\/pre><p><strong>Find PID with pgrep<\/strong><\/p><p>The <strong>pgrep<\/strong> command offers a more advanced way to find a process. It returns processes based on specific selection criteria that can match process names, known as a pattern.<\/p><pre class=\"wp-block-preformatted\">pgrep [options] [pattern]<\/pre><p>Here are some common options you can add:<\/p><ul class=\"wp-block-list\">\n<li><strong>-f<\/strong> &ndash; match against the full command line.<\/li>\n\n\n\n<li><strong>-l<\/strong> &ndash; list processes names and their IDs.<\/li>\n\n\n\n<li><strong>-n<\/strong> &ndash; select the newest of the matching processes.<\/li>\n\n\n\n<li><strong>-o<\/strong> &ndash; select the oldest of the matching processes.<\/li>\n\n\n\n<li><strong>-u<\/strong> &ndash; only match processes whose effective user ID is listed.<\/li>\n\n\n\n<li><strong>-x<\/strong> &ndash; match only processes whose name or command line exactly matches the pattern if <strong>-f<\/strong> is specified.<\/li>\n<\/ul><p>For example, to display the names and PIDs of all processes owned by<strong> <\/strong>the user <strong>john<\/strong>, you can use:<\/p><pre class=\"wp-block-preformatted\">pgrep -lu john<\/pre><p>The above command will return:<\/p><pre class=\"wp-block-preformatted\">1234 process_name_1<br><br>5678 process_name_2<br><br>...<\/pre><p><strong>View running processes with top<\/strong><\/p><p>The <strong>top<\/strong> command provides an interactive, real-time view of running processes. It shows the PIDs, users, amount of memory and CPU power each process uses, and running time.<\/p><p>To view a list of all active processes, run:<\/p><pre class=\"wp-block-preformatted\">top<\/pre><p>Here&rsquo;s an output you would see:<\/p><pre class=\"wp-block-preformatted\">top - 15:37:58 up&nbsp; 2:13,&nbsp; 2 users,&nbsp; load average: 0.00, 0.01, 0.05<br><br>Tasks:&nbsp; 95 total, &nbsp; 1 running,&nbsp; 94 sleeping, &nbsp; 0 stopped, &nbsp; 0 zombie<br><br>%Cpu(s):&nbsp; 0.0 us,&nbsp; 0.0 sy,&nbsp; 0.0 ni, 100.0 id,&nbsp; 0.0 wa,&nbsp; 0.0 hi,&nbsp; 0.0 si,&nbsp; 0.0 st<br><br>KiB Mem: &nbsp; 4045860 total,&nbsp; 3810124 free, &nbsp; 140408 used,&nbsp; &nbsp; 94808 buff\/cache<br><br>KiB Swap:&nbsp; 2097148 total,&nbsp; 2097148 free,&nbsp; &nbsp; &nbsp; &nbsp; 0 used.&nbsp; 3643028 avail Mem<br><br>PID USER&nbsp; &nbsp; &nbsp; PR&nbsp; NI&nbsp; &nbsp; VIRT&nbsp; &nbsp; RES&nbsp; &nbsp; SHR S&nbsp; %CPU %MEM &nbsp; &nbsp; TIME+ COMMAND<br><br>1 root&nbsp; &nbsp; &nbsp; 20 &nbsp; 0&nbsp; 169364 &nbsp; 8824 &nbsp; 6508 S &nbsp; 0.0&nbsp; 0.2 &nbsp; 0:05.14 systemd<br><br>2 root&nbsp; &nbsp; &nbsp; 20 &nbsp; 0 &nbsp; &nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; 0 S &nbsp; 0.0&nbsp; 0.0 &nbsp; 0:00.00 kthreadd<br><br>...<\/pre><p>To exit the <strong>top<\/strong> interface, press <strong>Q<\/strong>.<\/p><p><div class=\"protip\">\n                    <h4 class=\"title\">Listing process without commands<\/h4>\n                    <p>Hostinger users can list processes in their VPS without commands by asking the <a href=\"\/blog\/kodee\">Kodee AI assistant<\/a>. Simply enter a prompt like, \"Show all processes and their PID owned by the user root\" and Kodee will output the corresponding processes.<\/p>\n                <\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-understanding-kill-command-signals\">Understanding kill command signals<\/h3><p><strong>kill<\/strong> command signals are messages sent to processes to instruct them to perform specific actions. They are a fundamental part of Unix-based operating systems, allowing users and programs to control processes effectively.<\/p><p>You can view all available signals on Linux with the command below:<\/p><pre class=\"wp-block-preformatted\">kill -l<\/pre><p>It lists all signals along with their corresponding numbers and names, such as:<\/p><ul class=\"wp-block-list\">\n<li><strong>SIGTERM (Signal 15)<\/strong>. This signal asks for a process to terminate. The process can capture this signal, perform cleanup operations, and then exit. By default, the kill command sends <strong>SIGTERM<\/strong> if no other signal is specified.<\/li>\n\n\n\n<li><strong>SIGKILL (Signal 9)<\/strong>. It forcefully kills a process. The process cannot capture or ignore this signal, which results in an immediate termination. It should be used as a last resort when a process doesn&rsquo;t respond to <strong>SIGTERM<\/strong>.<\/li>\n\n\n\n<li><strong>SIGINT (Signal 2)<\/strong>. This is typically sent when you press <strong>Ctrl + C<\/strong> in the terminal. It interrupts a process and is usually used to stop a process running in the foreground.<\/li>\n\n\n\n<li><strong>SIGHUP (Signal 1)<\/strong>. Sent to a process when its controlling terminal is closed and often used to reload configuration files.<\/li>\n\n\n\n<li><strong>SIGQUIT (Signal 3)<\/strong>. Causes a process to terminate and produce a core dump file for debugging.<\/li>\n\n\n\n<li><strong>SIGSTOP (Signal 19)<\/strong>. Pauses a process without killing it, similar to pressing <strong>Ctrl + Z<\/strong> in the terminal.<\/li>\n\n\n\n<li><strong>SIGCONT (Signal 18)<\/strong>. Continues a process that was stopped by <strong>SIGSTOP<\/strong> or <strong>Ctrl + Z<\/strong>.<\/li>\n<\/ul><p>For instance, to kill a process with <strong>SIGTERM<\/strong>, execute the following:<\/p><pre class=\"wp-block-preformatted\">kill -15 [PID]<\/pre><p><strong>The importance of choosing the appropriate signal<\/strong><\/p><p>Using the correct <strong>kill<\/strong> signal based on the scenario and the desired impact ensures that processes are terminated in a controlled and predictable manner, especially when dealing with background tasks.<\/p><p>For example, the <strong>SIGTERM<\/strong> signal is preferred for safe process control, letting processes carefully save their state and exit. <strong>SIGKILL<\/strong>, while practical, should be sparingly used as it may lead to data loss or corruption.<\/p><p><div class=\"protip\">\n                    <h4 class=\"title\"> Suggested Reading<\/h4>\n                    <p>Follow our article to learn about some of the most commonly used <a href=\"\/uk\/tutorials\/linux-commands\">Linux commands<\/a>, strengthening your skills and familiarity with this operating system.<\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-kill-processes-in-linux\">How to kill processes in Linux<\/h2><p>In this section, we&rsquo;ll explore various ways to end processes in Linux for different scenarios.<\/p><h3 class=\"wp-block-heading\" id=\"h-how-to-kill-a-single-process-with-pid\">How to kill a single process with PID<\/h3><p>If you know the PID of the process you want to terminate, you can easily use the Linux <strong>kill<\/strong> command to send a signal. The following is its basic syntax:<\/p><pre class=\"wp-block-preformatted\">kill [signal] PID<\/pre><p>For example, to ask the process to end with the default <strong>SIGTERM<\/strong> signal and PID <strong>1234<\/strong>, execute:<\/p><pre class=\"wp-block-preformatted\">kill -15 1234<\/pre><p>If the process does not respond to <strong>SIGTERM<\/strong>, try using the <strong>SIGKILL<\/strong> signal to terminate it forcefully:<\/p><pre class=\"wp-block-preformatted\">kill -9 1234<\/pre><p>You can also send other signals based on your specific needs, such as:<\/p><pre class=\"wp-block-preformatted\">kill -2 1234&nbsp; # Sends SIGINT<\/pre><pre class=\"wp-block-preformatted\">kill -1 1234&nbsp; # Sends SIGHUP<\/pre><h3 class=\"wp-block-heading\" id=\"h-how-to-kill-multiple-processes\">How to kill multiple processes<\/h3><p>There might be situations where you need to terminate multiple processes simultaneously. Fortunately, the <strong>kill<\/strong> command can also send a signal to multiple PIDs at once, making it a powerful tool for managing Linux processes.<\/p><p>However, be cautious, as some processes might depend on others. Killing a parent process can also terminate other processes.<\/p><p>The basic syntax for killing multiple processes is:<\/p><pre class=\"wp-block-preformatted\">kill [signal] PID1 PID2 PID3<\/pre><p>Here&rsquo;s an example of ending processes with PIDs <strong>1234<\/strong>, <strong>5678<\/strong>, and <strong>91011<\/strong> using <strong>SIGTERM<\/strong>:<\/p><pre class=\"wp-block-preformatted\">kill -15 1234 5678 91011<\/pre><p>To send a signal to all processes in a group, use the negative PID of the group leader:<\/p><pre class=\"wp-block-preformatted\">kill -15 -1234<\/pre><p>This kills all processes in the group led by PID <strong>1234<\/strong>.<\/p><h3 class=\"wp-block-heading\" id=\"h-how-to-kill-a-process-with-the-pkill-command\">How to kill a process with the pkill command<\/h3><p>The <strong>pkill<\/strong> command lets you kill processes by name without first identifying their PIDs, making it simpler and more convenient to use than <strong>kill<\/strong>. It&rsquo;s also faster to type and execute, especially when dealing with multiple instances of the same process.<\/p><p>Below is the basic syntax of <strong>pkill<\/strong>:<\/p><pre class=\"wp-block-preformatted\">pkill [signal] [process name]<\/pre><p>For example, to kill a process named <strong>nginx<\/strong>, run:<\/p><pre class=\"wp-block-preformatted\">pkill -SIGTERM nginx<\/pre><p>If you want to terminate processes owned by a specific user:<\/p><pre class=\"wp-block-preformatted\">pkill -u john<\/pre><p>For instance, to end processes associated with a terminal <strong>pts\/1<\/strong>:<\/p><pre class=\"wp-block-preformatted\">pkill -t pts\/1<\/pre><p>You can also kill all processes in a specific process group, for example, PGID <strong>1234<\/strong>:<\/p><pre class=\"wp-block-preformatted\">pkill -g 1234<\/pre><p>To terminate the newest or oldest instance of a process, type the following:<\/p><pre class=\"wp-block-preformatted\">pkill -n nginx&nbsp; # Kill the newest instance of nginx<\/pre><pre class=\"wp-block-preformatted\">pkill -o nginx&nbsp; # Kill the oldest instance of nginx<\/pre><p>You can also combine multiple options to match processes based on specific criteria. For example, to kill processes from user <strong>john<\/strong> on terminal <strong>pts\/1<\/strong> in process group <strong>1234<\/strong> at once, execute the following:<\/p><pre class=\"wp-block-preformatted\">pkill -u john -t pts\/1 -g 1234<\/pre><h3 class=\"wp-block-heading\" id=\"h-how-to-kill-a-process-with-the-killall-command\">How to kill a process with the killall command<\/h3><p><strong>killall<\/strong> terminates all instances of a process by name and can target processes based on age, user, and running time.<\/p><p>It&rsquo;s ideal to manage processes with the same name across the system, compared to <strong>kill<\/strong> for individual processes and <strong>pkill<\/strong> for selectively managing multiple instances of a process.<\/p><p>The basic syntax of the <strong>killall<\/strong> command is:<\/p><pre class=\"wp-block-preformatted\">killall [options] [process_name]<\/pre><p>Here are some of its primary uses:<\/p><pre class=\"wp-block-preformatted\">killall nginx&nbsp; # Terminates all instances of nginx<\/pre><pre class=\"wp-block-preformatted\">killall -s SIGKILL nginx&nbsp; # Forcefully kills all instances of nginx<\/pre><pre class=\"wp-block-preformatted\">killall -u john nginx&nbsp; # Ends all nginx processes owned by the user john<\/pre><p>If you want to kill processes that have been running for a specific duration:<\/p><pre class=\"wp-block-preformatted\">killall -o 1h nginx<\/pre><p>This kills all <strong>nginx<\/strong> processes running for more than one hour.<\/p><p>To kill all instances of a process except a specific one:<\/p><pre class=\"wp-block-preformatted\">killall -v -I nginx<\/pre><p>You can exclude a specific <strong>nginx<\/strong> process from being killed with the above command.<\/p><p>Furthermore, to kill processes based on their CPU load or memory usage:<\/p><pre class=\"wp-block-preformatted\">killall -i -s SIGKILL nginx<\/pre><p>This sends an interactive prompt before killing each <strong>nginx<\/strong> process so you can confirm or deny each action.<\/p><h3 class=\"wp-block-heading\" id=\"h-how-to-kill-a-process-with-the-xkill-command\">How to kill a process with the xkill command<\/h3><p>The <strong>xkill<\/strong> command is designed for GUI-based environments like a Linux-installed laptop. With it, you can kill applications that have frozen or don&rsquo;t respond to standard termination commands with a simple click.<\/p><p>Here are some scenarios where <strong>xkill<\/strong> proves handy:<\/p><ul class=\"wp-block-list\">\n<li><strong>Unresponsive applications<\/strong>. If an application becomes unresponsive and you cannot close it using standard methods.<\/li>\n\n\n\n<li><strong>Frozen GUI elements<\/strong>. When certain GUI elements, such as windows or dialogs, freeze and don&rsquo;t allow interaction.<\/li>\n\n\n\n<li><strong>Quick termination<\/strong>. When you need to terminate a specific window or application quickly and easily without looking up its PID.<\/li>\n<\/ul><p>To use <strong>xkill<\/strong>, enter this command in your terminal:<\/p><pre class=\"wp-block-preformatted\">xkill<\/pre><p>After executing this command, your mouse cursor will change to an <strong>&times;<\/strong> icon. Then, move the cursor to the window of the unresponsive application and right-click on it. This will immediately kill the selected process.<\/p><p>Alternatively, if you know the unresponsive application&rsquo;s window ID, type:<\/p><pre class=\"wp-block-preformatted\">xkill -id &lt;window_id&gt;<\/pre><p>With this command, you can target and kill a specific window directly.<\/p><p>Please note that <strong>xkill<\/strong> doesn&rsquo;t natively support killing by class or name. However, you can use other tools in conjunction with it to achieve similar results. For example, use <strong>wmctrl<\/strong> to list windows and their IDs, and then run <strong>xkill<\/strong> with the appropriate ID.<\/p><p>To install <strong>wmctrl<\/strong>, run:<\/p><pre class=\"wp-block-preformatted\">sudo apt-get install wmctrl<\/pre><p>Once done, list all windows and their IDs:<\/p><pre class=\"wp-block-preformatted\">wmctrl -l<\/pre><p>The output will look something like this:<\/p><pre class=\"wp-block-preformatted\">0x03c00003&nbsp; 0&nbsp; hostname&nbsp; Firefox<br><br>0x04a00004&nbsp; 0&nbsp; hostname&nbsp; Terminal<br><br>0x05000005&nbsp; 0&nbsp; hostname&nbsp; Code<\/pre><p>Then run <strong>xkill<\/strong> with the desired ID, for instance:<\/p><pre class=\"wp-block-preformatted\">xkill -id 0x03c00003<\/pre><h3 class=\"wp-block-heading\" id=\"h-how-to-kill-a-process-with-the-top-command\">How to kill a process with the top command<\/h3><p>Last but not least, the <strong>top<\/strong> command provides a real-time, interactive view of resource usage and running processes. It&rsquo;s handy for identifying and terminating processes that consume excessive resources or become unresponsive.<\/p><p>As previously explained, you can type <strong>top<\/strong> in your terminal to start it. To navigate through the list of processes, use the <strong>arrow keys<\/strong>. Press <strong>Shift + P<\/strong> to sort processes by CPU usage, while <strong>Shift + M<\/strong> sorts them by memory usage.<\/p><pre class=\"wp-block-preformatted\">...<br><br>PID USER&nbsp; &nbsp; &nbsp; PR&nbsp; NI&nbsp; &nbsp; VIRT&nbsp; &nbsp; RES&nbsp; &nbsp; SHR S&nbsp; %CPU %MEM &nbsp; &nbsp; TIME+ COMMAND<br><br>1 root&nbsp; &nbsp; &nbsp; 20 &nbsp; 0&nbsp; 169364 &nbsp; 8824 &nbsp; 6508 S &nbsp; 0.0&nbsp; 0.2 &nbsp; 0:05.14 systemd<br><br>512 user&nbsp; &nbsp; &nbsp; 20 &nbsp; 0&nbsp; 120364 &nbsp; 6024 &nbsp; 2508 S &nbsp; 1.0&nbsp; 0.1 &nbsp; 0:02.04 firefox<br><br>789 user&nbsp; &nbsp; &nbsp; 20 &nbsp; 0&nbsp; 140364 &nbsp; 7624 &nbsp; 3208 R &nbsp; 2.0&nbsp; 0.3 &nbsp; 0:03.22 chrome<br><br>...<\/pre><p>Once you&rsquo;ve identified the process you want to end, press <strong>K<\/strong>.<\/p><p><strong>top<\/strong> will prompt you to enter the process&rsquo; PID you wish to kill. Then, you need to specify the signal to send to the process.<\/p><p>Press <strong>Enter<\/strong> to send the default <strong>SIGTERM<\/strong> signal, or type a different signal number if required.<\/p><p>For instance, to kill the <strong>chrome<\/strong> process with PID <strong>789 <\/strong>using <strong>SIGKILL<\/strong>:<\/p><pre class=\"wp-block-preformatted\">k<br><br>PID to kill: 789<br><br>Send signal (15): 9<\/pre><p>Additionally, to view processes owned by a specific user, start <strong>top<\/strong> with the <strong>-u<\/strong> option like the following:<\/p><pre class=\"wp-block-preformatted\">top -u john<\/pre><p>You can also customize the columns displayed within <strong>top<\/strong> by pressing <strong>F<\/strong>. This way, you can add or remove columns and sort by different criteria.<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>In this article, we covered various methods for terminating processes in Linux, including the <strong>kill<\/strong>, <strong>pkill<\/strong>, <strong>killall<\/strong>, <strong>xkill<\/strong>, and <strong>top<\/strong> commands. Each command offers different functionalities, allowing you to use them according to your needs.<\/p><p>Carefully managing processes is essential for maintaining system performance and stability. By familiarizing yourself with these commands, you can effectively handle unresponsive applications and optimize resource usage.<\/p><p>Lastly, always verify the processes you terminate to avoid accidental system issues and ensure your Linux machine runs smoothly.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-kill-a-process-in-linux-faq\">How to kill a process in Linux FAQ<\/h2><p>This section answers some of the most common questions about killing a process in Linux.<\/p><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1721047525658\"><h3 class=\"schema-faq-question\">What processes can you kill in Linux?<\/h3> <p class=\"schema-faq-answer\">You can kill both user and system processes in Linux. User processes owned by the user can generally be killed without issues. System processes owned by the system or root user require root permissions to kill and should be handled cautiously, as terminating them can cause system failure.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1721047537768\"><h3 class=\"schema-faq-question\">What is the difference between the kill and killall commands?<\/h3> <p class=\"schema-faq-answer\">The <strong>kill<\/strong> command requires a PID and terminates a specific process, making it ideal for precise control. Meanwhile, the <strong>killall<\/strong> command terminates all instances of a process by name, offering more flexibility for managing processes with the same name across the system.&nbsp;<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1721047543584\"><h3 class=\"schema-faq-question\">How do I find the PID of a process I want to kill?<\/h3> <p class=\"schema-faq-answer\">You can find the PID of a process using the <strong>ps<\/strong>, <strong>pidof<\/strong>, <strong>pgrep<\/strong>, or <strong>top<\/strong> commands. For example, use <strong>ps aux<\/strong>, <strong>pidof [process_name]<\/strong>, <strong>pgrep [process_name]<\/strong>, or <strong>top<\/strong> to list process IDs and details.<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>In Linux, managing running processes can help maintain system health and performance. Sometimes, you might need to terminate a process to free up system resources or address unresponsive applications. This practice, known as killing processes, ensures your system runs smoothly without unnecessary interruptions or resource drains. However, improperly stopping processes can lead to data loss [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/uk\/tutorials\/how-to-kill-a-process-in-linux\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":411,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to kill a process in Linux from the command line","rank_math_description":"To kill a process in Linux, you can use the kill command with the PID of the process you want to terminate. Learn more in this article.","rank_math_focus_keyword":"how to kill a process in linux","footnotes":""},"categories":[22644,22640],"tags":[],"class_list":["post-15849","post","type-post","status-publish","format-standard","hentry","category-managing-monitoring-and-security","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-kill-a-process-in-linux","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/tuer-processus-linux","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/cancelar-proceso-comando-kill-linux","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/linux-kill-process","default":0},{"locale":"ja-JP","link":"https:\/\/www.hostinger.com\/jp\/tutorials\/how-to-kill-a-process-in-linux","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-kill-a-process-in-linux","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-kill-a-process-in-linux\/","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-kill-a-process-in-linux\/","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/cancelar-proceso-comando-kill-linux","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/cancelar-proceso-comando-kill-linux","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/cancelar-proceso-comando-kill-linux","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-kill-a-process-in-linux","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-kill-a-process-in-linux","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-kill-a-process-in-linux","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-kill-a-process-in-linux","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/15849","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/users\/411"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/comments?post=15849"}],"version-history":[{"count":18,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/15849\/revisions"}],"predecessor-version":[{"id":124597,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/15849\/revisions\/124597"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/media?parent=15849"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/categories?post=15849"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/tags?post=15849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}