Signup/Sign In

Kill Command in Linux

Posted in Programming   MAY 18, 2023

    Linux is the backbone of the Internet, and it is used by DOS attackers and system admins, we use Linux for fun stuff like monitoring rogue processes. Linux is great, but it requires that you memorize commands just like words in a language, and one such word or command to memorize is killed.

    The kill command in the Linux or the Unix systems can terminate running processes and daemons. We use the kill command in combination with the PS command (which gives information regarding all the processes) can eliminate rouge processes that cannot be stopped on a Linux system otherwise. 64 different kill flags are available on Linux that can be sent to kill the running process.

    We use the PS command to view currently running processes. This command gives the current PID of the process.

    The syntax for the kill command

    The kill command follows this structure

    Kill <options> < arguments>

    The kill command has five options, and the argument is the process ID.

    Unlike most commands, help is not available with the double dash, as the kill is a shell built-in on many like Linux distributions. So instead, try pointing to the program at /bin slash kill with a double dash help or – each option and then the rest of the options are basically the type of signal to be sent and to view the signal types use - small L for names and capital L for the number and once you select the signal use – s and the number or name.

    How to use Kill on Linux?

    To use kill in the Linux systems, open your terminal on Linux, Now use PS - a to see all our processes, this helps you to know the process id (PID) of the process that you want to kill.

    The kill L command is like using grep, it will locate and kill all processes running with the name you specify without requiring the PID, there are basically 64 different signals that the kill command can send to a process. You may list them all typing kill—L.

    kill

    Among those 64 people, your five most common kill signals in their daily routine.

    Five most common kill signals

    1 = This stops and restarts a process with the same PID as it was previously, without assigning it with a new PID

    2 = This is the weakest kill and interrupts the process, here we do (control + C), it just breaks a process running on the PC.

    3= This Kills and core dump memory to a file memory to a file on the hard disk; with this, we keep the information.

    9= the strongest kill and that stops the process and sends the process to devise null

    15= This is the default kill, so if you type kill and don't specify an option, this kill would occur.

    When killing a process, you will use the PS command and pipe its output to the Grep command to find the process ID or ahead of the program or daemon you wish to kill

    For example; If you type PS aux in the terminal and pipe it to grip and look for G edit, this would find the pin for all instances of G edit running on the Linux system. You would then take the PID of the process from the previous command and pass it to the kill command to stop that process.

    If you want to exit from the terminal, then do control C to stop the process, which is something that we commonly do.

    kill <option> 1099

    Here, kill along with the options specified above is used to kill the process under a particular circumstance. We can use all the 64 different options listed above to kill the process, considering the level of action it could perform.

    Conclusion

    Sometimes if you are unable to close a process that sometimes contains the malware that was running on your system, then it is important to kill that process, Kill command in Linux helps you to kill such processes. The article gives you a brief idea of the kill command on Linux and how to kill a process.

    Hope you like this article.

    About the author:
    Tags:systemcommand-linelinux
    IF YOU LIKE IT, THEN SHARE IT
     

    RELATED POSTS