The kill
command is used to send a signal to a process. The signal can be used to terminate the process or to instruct it to perform some action, such as reloading its configuration file.
Here are some examples of how to use the kill
command in Linux/UNIX:
- To terminate a process with a specific process ID (PID):
kill PID
- To send a specific signal to a process:
kill -SIGNUM PID
where SIGNUM
is the signal number, and PID
is the process ID. For example, to terminate a process with a SIGTERM signal:
kill -TERM PID
- To send a signal to all processes with a specific name:
pkill -SIGNUM process_name
where process_name
is the name of the process, and SIGNUM
is the signal number.
- To send a signal to all processes owned by a specific user:
pkill -U username -SIGNUM
where username
is the name of the user, and SIGNUM
is the signal number.
- To list all available signal names and numbers:
kill -l
Note: Using the kill
command to terminate a process may cause data loss or other issues if the process is not given the opportunity to shut down cleanly. It is generally recommended to use other methods, such as sending a SIGHUP signal to instruct the process to reload its configuration file.