Chapter 3: Process Management

Foreword

We recommend that you do not use AI to do the exercises since you are in a learning phase.

Introduction

In a Linux system, process management is a fundamental aspect of system administration and application operation. A process is simply a program that is currently running. Linux, like all modern operating systems, uses processes to execute tasks and organize work.

Prerequisites

Info: If you don’t have a Linux environment available, you can register at https://killercoda.com and go here https://killercoda.com/playgrounds/scenario/ubuntu to get access to a virtual machine running Ubuntu 24.04 (without a graphical interface, of course!!) for 1 hour, freely renewable.

You will therefore see this view:




General information

A process is an instance of a program in execution. It can be as simple as a command launched in the terminal or as complex as a background application. Each process has its own memory space, its own unique identifier (PID), and information about its execution state. If process 2 was launched by process 1, it is called a child process. The process that launched it is called the parent process.


There are different types of processes in Linux:

TLDR (Quick summary)

Let’s type a little

To test 👨🏾‍💻👩🏾‍💻:


For your information, ps stands for process status. It lets us display the currently running processes. You’ll get output similar to:

PID    TTY          TIME CMD
380123 pts/3    00:00:00 bash
427931 pts/3    00:00:00 ps

Below is an explanatory table.

Column Meaning Example
PID Unique identifier assigned by Linux to each process. bash: 380123
ps: 427931
TTY Terminal the process is attached to. pts/* are pseudo-terminals, often opened during an SSH connection or a graphical terminal. pts/3
TIME CPU time used by the process since it was launched. 00:00:00 (minimal time for fast or idle processes)
CMD Command or program that the process originated from. bash (interactive shell)
ps (process display command)


From this result, we might ask ourselves two (2) questions:

  1. The ps command is itself a Linux process. When it is executed, it temporarily creates itself as a process, then analyzes the processes running at that precise moment. That’s why it naturally appears in its own results.

  2. By default, this command (ps) without any particular argument only displays the processes associated with its current terminal. This explains why we only see the shell (bash) we’re currently using, as well as the ps command itself.


To test 👨🏾‍💻👩🏾‍💻:




Process management

Commands to display running processes

Practical examples:


Reminder: The man command and the –help option (two dashes please 🫠) are your best friend.


Other commands

The pgrep and pkill commands

The pgrep command searches among the currently running processes for a process name and displays on standard output the PIDs matching the selection criteria.

The pkill command sends the specified signal (default SIGTERM) to every process matching the specified criteria.

Syntax:

Examples:




Training ⚔️

Exercise 1

Below is an example run:

# Download the challenge 1 script
curl -LO https://raw.githubusercontent.com/N0vachr0n0/NoFD/refs/heads/main/PRM_EXO_1.sh

# Make it executable
chmod +x PRM_EXO_1.sh

# Run it to start the challenge
./PRM_EXO_1.sh

Exercise 2

It’s over here: https://sadservers.com/scenario/saint-john



Feedback

Let us know what you think of this chapter.

👉🏾 Click here