0% found this document useful (0 votes)
24 views

Terminating A Process - Linux

The document discusses how to terminate specific processes running on a Linux machine. It explains how to use the ps and grep commands to find processes by name. It then describes using the kill command with sudo to terminate processes using their process ID. It provides an example of finding and terminating two malicious processes called "totally_not_malicious". Finally, it discusses using the same approach to find and terminate multiple processes containing the word "razzle" in their name.

Uploaded by

arunajith897
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Terminating A Process - Linux

The document discusses how to terminate specific processes running on a Linux machine. It explains how to use the ps and grep commands to find processes by name. It then describes using the kill command with sudo to terminate processes using their process ID. It provides an example of finding and terminating two malicious processes called "totally_not_malicious". Finally, it discusses using the same approach to find and terminate multiple processes containing the word "razzle" in their name.

Uploaded by

arunajith897
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Terminating a specific process

The ps -aux command allows you to list all currently running processes on a Linux machine. However, the list of processes is often super long,
which makes finding a specific process pretty tough. To filter the processes you're interested in, you can pipe the output of ps through grep.

There are two "malicious" processes currently running on your machine, called "totally_not_malicious". You can run ps and grep to find them,
using this command:

ps -aux | grep "totally_not_malicious"


content_copy
You should see output similar to this. The top two lines are the two processes, while the last line is the grep process you just used to search for
them. Check out the four-digit numbers on the left of each of the rows; these are the process IDs.

To stop a process, you can use the kill command. You need to use sudo to have permission to stop them. You also need to specify the ID of the
process, which will likely be different on your machine than what's shown above (the ID is outlined in light blue):

sudo kill [PROCESS ID]


content_copy
After killing the processes, you can verify that they're no longer running by running the original command again:

ps -aux | grep "totally_not_malicious"


content_copy

Click Check my progress to verify the objective.

Stop the malicious processes


Check my progress

Terminating multiple processes


There are also multiple processes running on your computer containing the word "razzle". You can find them in the same way that you found the
previous process using ps. Because grep doesn't look for full matches, it can be used to find any process that contains a specific substring:

ps -aux | grep "razzle"


content_copy
The below shows all six processes that contain the word "razzle". (Again, you can ignore the last process because it's the process running grep.)
To kill each of the processes, you can use the same kill command as before, substituting in each process ID:

sudo kill [PROCESS ID]


content_copy
To verify that the processes were successfully stopped, you can use the same command you used to find them in the first place:

ps -aux | grep "razzle"


content_copy
You should only see the process for the grep command, indicating that the other processes are no longer running:

Click Check my progress to verify the objective.

You might also like