Using the kill command: The kill command sends a signal to a process, requesting it to terminate. The default signal is 'SIGTERM', which allows the process to perform cleanup tasks before exiting gracefully. To kill a process, you need to know its process ID (PID).
You can use the ps command to list the running processes and their PIDs, and then use kill followed by the PID to terminate the process. For example:
ps -ef: This option displays information about all processes in a wide format, including the UID, PID, PPID, CPU usage, memory usage, and the command associated with each process. It shows all processes from all users.
Here's an example of using the ps -ef command in Unix-like systems:
Let's assume you have identified the process you want to kill and obtained its Process ID (PID) using the ps command or other means. In this example, we'll use PID 2 as an example.
shell
$ kill 2
By executing the above command, you send a termination signal (SIGTERM) to the process with PID 2. This signal requests the process to gracefully terminate and perform any necessary cleanup before exiting.
No comments:
Post a Comment