User Tools

Site Tools


unix_commands:kill

The kill command in Linux and Unix-like systems is used to send a signal to a process to terminate it. The signal can be specified as a number or as the name of a signal, such as SIGTERM or SIGKILL.

The basic syntax for kill is:

kill [options] pid

Where pid is the process ID of the process to be killed and options are any options that modify the behavior of the command.

Examples for Linux:

  • To send the default signal (SIGTERM) to a process with process ID 123456:
kill 123456
  • To forcefully terminate a process with process ID 123456:
kill -9 123456
  • To list all the process and their process IDs
ps -ef
  • To find the process ID of a running process with name 'httpd'
pgrep httpd
  • To forcefully terminate the process(es) with name 'httpd'
killall -9 httpd

Examples for FreeBSD:

  • To send the default signal (SIGTERM) to a process with process ID 123456:
kill 123456
  • To forcefully terminate a process with process ID 123456:
kill -9 123456
  • To list all the process and their process IDs
ps -ax
  • To find the process ID of a running process with name 'httpd'
pgrep httpd
  • To forcefully terminate the process(es) with name 'httpd'
killall -9 httpd

As an alternative, you can also use

pkill -9 httpd

It's worth noting that the kill command sends a signal to a process, which may or may not cause the process to terminate immediately. Some processes may have been programmed to ignore certain signals, or to perform a specific action before terminating.

As with any command that can terminate a running process, it is important to use caution when using the kill command and to ensure that you are sending the signal to the correct process.

unix_commands/kill.txt ยท Last modified: 2023/01/17 15:50 by admin

CIFNet is a leading hosting solution provider, offering a wide range of services including IP bandwidth, co-location, VMware and KVM hosting.
Host Your Site with CIFNet!