Kill and kill processes in CentOS
After collecting and sorting out the relevant linux killing process materials, I would like to recommend this article to you here. I hope you will see a lot of gains in the future.
1. kill
Purpose: kill a process based on the process number.
Usage: kill [signal code] process ID
Example:
[Root @ localhost ~] # Ps auxf | grep httpd
Note: kill-9 to force termination and exit
Example [root @ localhost ~] # Ps aux | grep gaim
Or [root @ localhost ~] # Pgrep-l gaim 5031 gaim
5031 gaim
[Root @ localhost ~] # Kill-9 5031
Special usage:
Kill-STOP [pid]
Send SIGSTOP (17,19, 23) to stop a process without killing the process in linux.
Kill-CONT [pid]
Send SIGCONT (, 25) to start a stopped process again.
Kill-KILL [pid]
Send SIGKILL (9) to force the process to stop immediately without cleaning.
Kill-9-1
Terminate all processes you have.
2. killall
Purpose: directly kill all processes by program name
Usage: name of the program that is running killall
Example:
[Root @ localhost beinan] # pgrep-l gaim 2979 gaim
[Root @ localhost beinan] # killall gaim
Note: This command can use the-9 parameter to force the process to be killed.
3. pkill
Purpose: directly kill all processes by program name
Usage: # Name of the running program
Example:
[Root @ localhost beinan] # pgrep-l gaim 2979 gaim
[Root @ localhost beinan] # pkill gaim
4. xkill
Purpose: Kill the desktop graphic interface program.
Application Scenario example: When firefox crashes and cannot exit, you can click the mouse to kill firefox.
When xkill is running and the icon of the personal brain is displayed, it will be okay if any graphics program crashes.
If you want to terminate xkill, right-click to cancel it;
Call method:
[Root @ localhost ~] # Xkill
◆ Note:
KILLALL
NAME)
Killall-kill a process by name in linux
SYNOPSIS (Overview)
Killall [-egiqvw] [-signal] name...
Killall-l
Killall-V
DESCRIPTION)
Killall sends a signal to all processes that run any specified command. If no signal name is specified, it sends SIGTERM ..
The signal can be specified by name (such as-HUP) or number (such as-1). The signal 0 (check whether the process exists) can only be specified by number.
If the command name includes a slash (/), the process executing the specific file will be killed, which is irrelevant to the process name.
If no process can be killed for the commands listed, killall returns a non-zero value. If at least one process is killed for each command, killall returns 0. The Killall process will never kill itself (but it can kill other killall processes ).
OPTIONS)
-E requires exact matching for long names. if a command name is longer than 15 characters, the entire name may not be used (overflow ). in this case, killall will kill all processes that match the first 15 characters of the name. with the-e Option, such records will be ignored. if the-v option is specified, killall prints a message for each ignored record.
-G kills the process that belongs to the process group. The kill signal is sent only once to each group, even if the same process group contains multiple processes.
-I interaction method: Ask for confirmation information before killing a process in linux.
-L list all known signal names.
-If no process is killed, q will not complain.
-V indicates whether the report signal is successfully sent.
-V displays the version information.
-W waits for all killed processes to die. killall checks whether any killed process still exists once per second and returns only when all the processes are dead. note: If the signal is ignored or does not work, or the process stays in the zombie state, killall may wait permanently.
FILES)
The location of the/proc file system.
KNOWN bugS (known bugs)
Killing files only takes effect for executable files that have been opened during execution. That is, a hybrid executable file cannot be killed in this way.
It should be warned that the input of killall name may not produce the expected results on non-Linux systems, especially when privileged users perform the operation with caution.
In the gap between the two scans, if the process disappears and is replaced by a new process with the same PID, killall-w cannot detect it.