We have used the command ps
in the introduction. Let's learn more about it:
$ ps
$ ps –f
We can see the process ID in the PID
column and the parent process ID in the PPID
column in the preceding output.
$ ps –lf
In the preceding output, the column with S
(state) shows the current state of a process, such as R
for running and S
for suspended state.
$ ps –ef
The process names in []
are kernel threads. If you are interested in more options to learn about the ps
command, you can use the following command:
$ man ps.
To find a particular process, you can use the following command:
$ ps –ef | grep "process_name"
The command with grep
will display the process with process_name
.
$ kill pid_of_process_to_be_killed
$ kill
command, you may need to pass additional option to ensure that the required process is killed, which is shown as follows:$ kill -9 pid_of_process_to_be_killed
$ pkill command_name $ pkill sleep
Or:
$ pkill -9 command_name
kill
, enter following command:$ kill –l
This displays all the signals or software interrupts used by the operating system. When we enter the $ kill
command, the operating system sends the SIGTERM
signal to the process. If the process is not killed by this command, then we enter the following command:
$ kill -9 process_name
This sends SIGKILL
to the process to be killed.