These two commands are used to send signals to processes. The kill command requires a process number as an argument, while killall requires a command name.
Both of these commands can optionally receive a signal number as an argument. By default, they both send the signal 15 (TERM) to the relevant process(es). For example, if you want to kill the process with PID 785, you enter the command:
$ kill 785 |
$ kill -9 785 |
$ killall -9 netscape |
top is a program all in one: it simultaneously fulfills the functions of ps and kill. It is a console mode program, so you start it from a terminal, as shown in figure 5-1.
The program is entirely keyboard controlled. You can access help by pressing h. Here are some of the commands you can use.
k: this command is used to send a signal to a process. top will then ask you for the process PID followed by the number of the signal to be sent (15 by default);
M: this command is used to sort processes by the amount of memory they take up (field %MEM);
P: this command is used to sort processes by the CPU time they take up (field %CPU; this is the default sort method);
u: this command is used to display a given user's processes, top will ask you which one. You need to enter the user's name, not his UID. If you do not enter any name, all processes will be displayed;
i: this command acts as a toggle; by default, all processes, even sleeping ones, are displayed; this command ensures that only processes currently running are displayed (processes whose STAT field states R, Running) and not the others. Using this command again takes you back to the previous situation.