kill

From Initq

Jump to: navigation, search

kill is a command used to send simple messages to processes running on the system. By default, the message sent is the "termination" signal, which requests that the process exit. But kill is something of a misnomer; the signal sent may have nothing to do with process killing. The kill command is a wrapper around the kill() system call, which sends signals to processes or process groups on the system, referenced by their numeric process IDs (PIDs) or process group IDs (PGIDs). kill is always provided as a standalone utility, but most shells have built-in kill commands that may slightly differ from it.

Contents

Flags

  • -l lists all the kill signals
  • -9 signal kill

Status of dd

When you are copying with dd you might want to get the status of what dd is doing.

$ pgrep -l '^dd$'
6074 dd
 
lexiana:~# ps -eaf | grep dd
root         2     0  0 18:52 ?        00:00:00 [kthreadd]
root      6074  5942 11 20:37 pts/0    00:02:52 dd if /dev/sda of sda.iso
root      6321  5851  0 21:02 pts/1    00:00:00 grep dd
 
$ kill -USR1  6074
 
60345193+0 records in
60345193+0 records out
30896738816 bytes (31 GB) copied, 1597.27 s, 19.3 MB/s
 
$ watch -n 10 kill -USR1 6074

-1, -2, -9

kill with -1 and -2 before uses -9.

kill -1 5678

Okay, the process is really irritating, let me force kill it,

kill -9 5678

killall

Some process may have multiple instances, killing the process one by one with PID is nightmare, so kill them all one shot!

  • killall gaim
  • killall -9 gaim

Killall5

Just type killall5 and every active process will get killed except your login session:

# netstat
# netstat -tulpn
# killall5
# netstat -tulpn
Personal tools