23. kill_command - muneeb-mbytes/linux_course GitHub Wiki

Kill Command

kill command in Linux (located in /bin/kill), is a built-in command which is used to terminate processes manually.

kill command sends a signal to a process which terminates the process. If the user doesn’t specify any signal which is to be sent along with kill command then default TERM signal is sent that terminates the process.


kill %

This command is use to kill the running process with the help of job id .

Syntax : kill %[ Job_ID]

Jobs (intro)

Jobs command is used to list the jobs that you are running in the background and in the foreground.

If the prompt is returned with no information no jobs are present.

**Syntax **: jobs [JOB] (To display the status of jobs in the current shell)

After getting the status through jobs command , you can see the process id of the running process.

After that use the kill command to kill the running process.

The Figure.1. show the kill % command working .

Untitled Diagram drawio (11)

                          Figure.1. This image show the working of kill % command.

GIF.1. shows the whole process from sourcing scripting file till the output.

kill

                                           GIF.1. kill % output GIF 

Github lab link : https://github.com/muneeb-mbytes/linux_course/blob/b7_Team_SiliconCrew/kill_commands/kill_jobs.csh


kill -9

Firstly, need to understand about ps command , refer to the page - ps

kill -9 is a useful command when you need to shut down an unresponsive service. Run it similarly as a regular kill command:

Syntax : kill -9 [process ID]

Steps are as follows- 1.ps command is used to list the currently running processes and their PIDs along with some other information depends on different options.

2.After getting the process ID .Use the 'kill -9' command to kill the particular process .

The Figure.2. show the working of kill -9 command .

Untitled Diagram drawio (12)

                                Figure.2. Kill -9 command .

GIF.2. shows the whole process from sourcing scripting file till the output.

ps

                                           GIF.2. kill -9 output GIF 

Github lab link : https://github.com/muneeb-mbytes/linux_course/blob/b7_Team_SiliconCrew/kill_commands/kill_ps.csh


To learn whoami command:https://github.com/muneeb-mbytes/linux_course/wiki/24.-whoami