Linux Process Terminating

LinuxLinuxBeginner
Practice Now

Introduction

Welcome to the Paranormal Academy of Technological Advancement, a place where extraordinary talent and cutting-edge technology come together. As a super-powered student at the Academy, your latest mission is to master the art of terminating rogue processes that are draining the resources of the Academy's mainframe computer system. Your goal? Master the use of the kill command to gracefully shut down processes without compromising the integrity of the system.

In a world where every nanosecond counts, you are tasked with maintaining the equilibrium of the server realm. Your mission, should you choose to accept it, is to become adept at identifying, managing and terminating processes running on a Linux server. The Academy relies on your swift action and expertise to prevent system overloads caused by runaway processes. Fasten your cape, the fate of the digital cosmos is in your hands!


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/ProcessManagementandControlGroup(["`Process Management and Control`"]) linux/ProcessManagementandControlGroup -.-> linux/kill("`Process Terminating`") subgraph Lab Skills linux/kill -.-> lab-271315{{"`Linux Process Terminating`"}} end

Identifying Processes

In this step, you will learn how to identify processes on a Linux system. This is crucial before you can terminate them. Use the ps command to list all running processes. We will create a sample process that simulates a runaway task.

Start by running a simple sleep command in the background:

sleep 300 &;sleep_pid=$!

Now, list all the running processes:

ps -aux

-a: Shows all processes, including other users' processes and processes without a terminal.

-u: Displays detailed information about processes based on the user, including user name, process ID (PID), CPU usage, memory usage, etc. -x: Displays processes without a remote terminal.

-x: Displays processes that do not control a terminal.

Look for the sleep process in the output. Note the process ID (PID), as you'll need it for terminating the process later. Make sure you're comfortable identifying processes before you proceed.

Terminating Processes with 'kill'

Once you've identified the target process, it's time to terminate it. The kill command is very simple to use, but it requires the PID of the process you want to stop.

To terminate the sleep process that you started earlier, use:

kill <PID>

Replace <PID> with the actual process ID you obtained from Step 1. If done correctly, the sleep process should no longer appear in the list of running processes.

To confirm that the process has terminated, list the processes again:

ps -aux

The sleep process should not be present in the output. Congratulations! You have terminated your first process.

Summary

In this lab, you have embarked on a journey through the command-line interface to exercise your powers over Linux processes. You have learned how to identify processes with the ps command and mastered the art of terminating them using kill. By honing these skills, you ensure the safety and performance of the Paranormal Academy's technological infrastructure.

Your mission was not only about learning commands but also about being diligent and precise, key traits for a super-powered individual in any high-stakes digital environment. Celebrate your achievements and continue to practice your newfound skills; they are invaluable in the realm of Linux administration.

Other Linux Tutorials you may like