Terminate Processes by Name and ID

LinuxLinuxBeginner
Practice Now

Introduction

In this challenge, you need to kill the process with some specific program.

Achievements

  • kill - Send a signal to a process
  • killall - Kill all processes by name
  • pkill - Kill all processes by name

Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"]) linux(("`Linux`")) -.-> linux/InputandOutputRedirectionGroup(["`Input and Output Redirection`"]) linux(("`Linux`")) -.-> linux/TextProcessingGroup(["`Text Processing`"]) linux(("`Linux`")) -.-> linux/UserandGroupManagementGroup(["`User and Group Management`"]) linux(("`Linux`")) -.-> linux/SystemInformationandMonitoringGroup(["`System Information and Monitoring`"]) linux(("`Linux`")) -.-> linux/ProcessManagementandControlGroup(["`Process Management and Control`"]) shell(("`Shell`")) -.-> shell/BasicSyntaxandStructureGroup(["`Basic Syntax and Structure`"]) shell(("`Shell`")) -.-> shell/AdvancedScriptingConceptsGroup(["`Advanced Scripting Concepts`"]) linux/BasicSystemCommandsGroup -.-> linux/sleep("`Execution Delaying`") linux/InputandOutputRedirectionGroup -.-> linux/pipeline("`Data Piping`") linux/InputandOutputRedirectionGroup -.-> linux/redirect("`I/O Redirecting`") linux/TextProcessingGroup -.-> linux/grep("`Pattern Searching`") linux/UserandGroupManagementGroup -.-> linux/sudo("`Privilege Granting`") linux/SystemInformationandMonitoringGroup -.-> linux/ps("`Process Displaying`") linux/ProcessManagementandControlGroup -.-> linux/kill("`Process Terminating`") linux/ProcessManagementandControlGroup -.-> linux/killall("`Multi-Process Killing`") linux/ProcessManagementandControlGroup -.-> linux/pkill("`Pattern-Based Killing`") shell/BasicSyntaxandStructureGroup -.-> shell/comments("`Comments`") shell/AdvancedScriptingConceptsGroup -.-> shell/adv_redirection("`Advanced Redirection`") subgraph Lab Skills linux/sleep -.-> lab-31{{"`Terminate Processes by Name and ID`"}} linux/pipeline -.-> lab-31{{"`Terminate Processes by Name and ID`"}} linux/redirect -.-> lab-31{{"`Terminate Processes by Name and ID`"}} linux/grep -.-> lab-31{{"`Terminate Processes by Name and ID`"}} linux/sudo -.-> lab-31{{"`Terminate Processes by Name and ID`"}} linux/ps -.-> lab-31{{"`Terminate Processes by Name and ID`"}} linux/kill -.-> lab-31{{"`Terminate Processes by Name and ID`"}} linux/killall -.-> lab-31{{"`Terminate Processes by Name and ID`"}} linux/pkill -.-> lab-31{{"`Terminate Processes by Name and ID`"}} shell/comments -.-> lab-31{{"`Terminate Processes by Name and ID`"}} shell/adv_redirection -.-> lab-31{{"`Terminate Processes by Name and ID`"}} end

Send Signal To Process

kill is a command to send a signal to a process. We have run a sleep process in the background. Now you need use kill to send a signal to kill it.

Requirements

  • Send a signal to kill the sleep process
  • Just use the process ID
  • Only use kill to kill the process

Kill All Process

kill can be used to kill a process by name. The killall command is used to kill all processes by name.

Requirements

  • Kill all nginx processes
  • Use killall or pkill to kill all nginx processes

Summary

Congratulations! You have successfully completed this challenge.

In this challenge, you learned how to kill a process with some specific program.

Keep learning and have fun!

Other Linux Tutorials you may like