Article Title: send signals to processes: kill, killall, and top. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
These two commands are used to send signals to processes. The kill command requires the process number as the parameter, while the killall Command requires the process name.
In addition, you can add the signal number to be sent as the parameter after the two commands. By default, they all send signals to related processes 15 (TERM ). For example, if you want to terminate a process whose PID is 785, enter the following command:
$ Killed 785
If you want to send a signal 19 (STOP) to it, enter:
$ Kill-19 785
Assume that you know the command name of the process to be terminated. You can terminate a process by using this name, instead of using ps to find the process ID:
$ Killall-9 mozilla
In any case, you can only terminate your own processes (unless you are the root user), so when you run multi-user systems, you do not have to worry about your "Neighbor" processes, they will not be affected.
Integrated ps and kill: top
The top program completes ps and kill functions at the same time, and can be used to monitor the CPU and memory usage and execution time of processes in real time. "Use top monitoring process.
Figure top monitoring process
The top tool is fully controlled by the keyboard. Press h to access the help information. The most useful command is as follows:
K: used to send signals to a process. Top then you will be asked about the PID of your process and the serial number or name of the signal to be sent (default: TERM, that is, signal 15 );
M: processes are sorted by memory usage (% MEM column;
P: processes are sorted by CPU usage time (% CPU by default;
U: displays the process of a given user. Top will ask you which user it is. Enter the user name instead of his UID. If you do not enter any name, all processes are displayed;
I: All processes, including sleep processes, are displayed by default. This command ensures that only processes currently running are displayed (processes whose STAT column is R (run ). Enter the command again to display all processes.
R: changes the priority of the selected process.