{"id":8295,"date":"2021-07-15T10:33:54","date_gmt":"2021-07-15T10:33:54","guid":{"rendered":"https:\/\/linuxways.net\/?p=8295"},"modified":"2021-07-15T10:33:54","modified_gmt":"2021-07-15T10:33:54","slug":"how-to-use-pkill-command","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/how-to-use-pkill-command\/","title":{"rendered":"How to Use pkill Command"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>pkill is a command line used to send terminated signals to processes. The signal can be sent to any process by invoking the full name or shortened name.<\/p>\n<p>This article will describe the details of how to use the pkill command in Linux.<\/p>\n<h2>The running processes<\/h2>\n<p>You can list all running processes on your Ubuntu machine by running the following command:<\/p>\n<pre>$ top<\/pre>\n<p>Output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1610\" height=\"828\" class=\"wp-image-8296\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-373.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-373.png 1610w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-373-300x154.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-373-1024x527.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-373-768x395.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-373-1536x790.png 1536w\" sizes=\"auto, (max-width: 1610px) 100vw, 1610px\" \/><\/p>\n<p>Press Ctrl + C to stop<\/p>\n<h2>Using the pkill command<\/h2>\n<p>This is its syntax:<\/p>\n<pre>pkill [option] pattern<\/pre>\n<p><strong>pattern<\/strong><\/p>\n<p>Invokes an extended regular expression that matches a process or command-line name.<\/p>\n<p>If you use pkill command-line without [option], <strong>15<\/strong> (-TERM) signal will be sent by pkill to the PID. (Process ID)<\/p>\n<p>Linux users usually use the three types of signals as below:<\/p>\n<p>1 (HUP): reload a process<\/p>\n<p>-9 (KILL): kill a process<\/p>\n<p>15 (TERM): stop a process gracefully<\/p>\n<p>For example:<\/p>\n<p>$ pkill -9 chrome<\/p>\n<p>The above command will close the chrome browser.<\/p>\n<p>kill -l is used to list all the signals you can use.<\/p>\n<p>Output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1328\" height=\"540\" class=\"wp-image-8297\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-374.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-374.png 1328w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-374-300x122.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-374-1024x416.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-374-768x312.png 768w\" sizes=\"auto, (max-width: 1328px) 100vw, 1328px\" \/><\/p>\n<p>There are 3 different ways to specify the signals:<\/p>\n<ul>\n<li>using a number (e.g., -9)<\/li>\n<li>with the \u201cSIG\u201d prefix (e.g., -SIGKILL)<\/li>\n<li>without the \u201cSIG\u201d prefix (e.g., -KILL)<\/li>\n<\/ul>\n<p>For demonstration, in order to kill the oldest created screen:<\/p>\n<pre>$ pkill -9 -o screen<\/pre>\n<p>To reload the gitlab-runner process, run:<\/p>\n<pre>$ sudo pkill -HUB gitlab-runner<\/pre>\n<h2>Conclusion<\/h2>\n<p>You\u2019ve already gone through the details of how to use the pkill command in Linux.<\/p>\n<p>If you have any comments, please let me know. Thanks for reading.<\/p>","protected":false},"excerpt":{"rendered":"<p>Introduction pkill is a command line used to send terminated signals to processes. The signal can be sent to any process by invoking the full name or shortened&hellip;<\/p>","protected":false},"author":1,"featured_media":8426,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,4,5,83,165,2],"tags":[419],"class_list":["post-8295","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-debian","category-mint","category-opensuse","category-red-hat","category-ubuntu","tag-pkill-command"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/8295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=8295"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/8295\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/8426"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=8295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=8295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=8295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}