3

Starting my adventure with Linux a couple of years back, most tutorials and older, more experienced colleagues suggested using the command 'kill', sort of like a replacement for the Process Manager from Windows for a convert. But I also got (not sure if correctly) a sense of pro smugness about this command.

However, based on my own inquires I soon stared to use the 'killall' function, as I always had a problem with PIDs. However I just now learned that there is also a command 'pkill', which basically does the same thing. Also I learned that the proper way to use 'kill' is to use 'ps -A | grep ...'.

But isn't this procedure exactly the same thing as just using 'pkill', or 'killall'? (I've read What's the difference between 'killall' and 'pkill'?, so I know that those 2 are a little different.)

Why use kill at all, when we still have to do the identification: name of the process -> PID in order to use 'kill'?

Lurco
  • 157

1 Answers1

5

kill is an important part of Unix because it can kill a specific process even if another process has the same name. A Unix/Linux system will have kill but it may not have pkill or killall: in general, all Linux/Unix applications will always behave like kill exists on the system. Every admin should know how to use kill as it calls directly the system's inner process killing function and is less likely to have a bug, because it is simple.
Do not remove kill from your system or it will stop working.

kill is used very often in the system itself: the applications can ignore the name of a process and use the PID which is different for every process; also, if an application needs to memorize a huge number of processes it is always better to memorize them as PIDs, because a number eats less memory than a string. Of course there are may other secondary implications that should be discussed on a specialized programming forum.

In your daily routine, you can use killall or pkill without fear. :-)
Please, feel free to comment under here if you have more questions and don't forget to press the left UP arrow and mark as favorite if I'm of any help.

  • 1
    Thanks for your question. Kill can be removed, like any system utility, because not every shell has builtins and not every Linux system has the same shell. Builtins are an "extra feature" to provide a light alternative to standard system utilities and offer a chance to recover the system in case the system gets damaged/misconfigured. If the shell that you use is bash (or any Open Source shell), you can edit the source code and create your own version without the builtins; of course, you can replace your actual shell at any time. – Lorenzo Ancora Jul 17 '14 at 21:54