The kill command can be used to end a process. For example, let's say the gedit program is using process ID (PID) 16674. The kill command followed by 16674 will end the gedit process.
[john.doe@server1 ~]# kill 16674
The kill command can use the PID or Job ID number of the process to end. However, the kill command cannot accept the name of the process. For example, kill gedit cannot be used to end the gedit process. Instead, the killall command can be used to end a process using the process name.
The kill command can use different signals. A signals represents how a process should be ended. For example, the terminate signal is less aggresive than the quit signal. Following are some of the common signals.
When a certain signal is not specified, the terminate signal is used.
The kill command followed by the signal name or signal number can be used to end a process with a particular signal. In this example, the hangup signal is used.
[john.doe@server1 ~]# kill -1 16674
In this example, the quit signal is used.
[john.doe@server1 ~]# kill -sigquit 16674
Let's take an example where gedit is opened in the foreground, and then Ctrl + Z is issued in the Terminal to stop gedit. Gedit remains open, and the kill command with the default terminate signal fails to end gedit.
In this scenario, using a different kill signal should end gedit. The kill signal (9) is able to end gedit.