Linux Mastery

The Human Knowledge Project


03 — Processes, Memory & the Running System

Why This Chapter Matters

Every application you open becomes alive.

Your web browser.

Your terminal.

Your text editor.

Your music player.

Every one of them begins life as a program stored on disk.

When Linux starts that program, it becomes a process.

Processes are the living, active part of an operating system.

Understanding processes is one of the biggest steps toward understanding how Linux actually works.

1. What Is a Process?

A process is a running program.

When you launch:

Linux creates one or more processes.

Linux systems often run many processes simultaneously.

Some belong to:


2. Program vs. Process

Beginning Linux users often confuse programs and processes.

Although they are closely related, they are not the same thing.

A program is a collection of instructions stored on disk.

A process is a program that is currently running.

Think of it this way:

A blueprint describes a house.

A blueprint is not a house.

Likewise:

A program describes work.

A process performs work.

One program may produce many different processes.

For example, you can open several terminal windows at the same time.

Each terminal is a separate process, even though they all began from the same program.

THKI Memory Aid

Program → Stored

Process → Running

3. Viewing Running Processes

To display running processes:


ps

A more detailed view:


ps aux

Observe:

Important columns:


## USER
PID
## %CPU
## %MEM
## COMMAND

PID means:

Each running process has its own PID.


4. Real-Time Process Monitoring

Linux can display live system activity.

Run:


top

Observe:

To exit:


q

A friendlier alternative:


htop

If not installed:


sudo apt install htop

5. Understanding Memory

Linux uses:

To display memory usage:


free -h

Options:


-h

means:

Observe:

Linux often uses unused RAM for caching to improve performance.

Unused RAM is often considered wasted RAM.


6. System Uptime & Load

Linux systems continuously track:

To display uptime and system load:


uptime

Example output:


14:02:11 up 2 days, 3:17, 3 users, load average: 0.42, 0.51, 0.48

Meaning:

| Field | Meaning |

| --------------- | -------------------------------- |

| 14:02:11 | current system time |

| up 2 days, 3:17 | how long system has been running |

| 3 users | logged-in users |

| load average | system workload averages |

The three load-average numbers commonly represent:

These values estimate how heavily the CPU and scheduler are being used.

Low values usually indicate:

High values may indicate:

System administrators use uptime and load monitoring to:

Long uptimes may also indicate system stability.


7. Foreground and Background Jobs

Some programs occupy the terminal while running.

Example:


ping google.com

To stop:


ctrl + C

You can launch a program into the background using:


program &

Example:


firefox &

To view background jobs:


jobs

Why run programs in the background?

Linux allows programs to continue running while the terminal remains available for additional commands.

This is useful when:

Example:


firefox &

The shell launches Firefox while immediately returning control of the terminal.

Without:


&

the terminal may remain occupied by the running process.

Background processing is one of the foundations of multitasking in Unix/Linux systems.


8. Killing Processes

Sometimes processes freeze or misbehave.

To terminate a process:


kill PID

Example:


kill 2481

To force termination:


kill -9 PID

Use force carefully.

Abrupt termination may:


9. Process Trees

Processes often create child processes.

To view process hierarchy:


pstree

If unavailable:


sudo apt install psmisc

Linux systems are built from many interacting processes.

(more in Appendix A)


10. The Linux Scheduler

Linux rapidly switches CPU attention among processes.

This creates the appearance of simultaneous execution.

The scheduler decides:

Modern systems may manage thousands of active processes.

(See Appendix A — Scheduler)


11. Daemons

Many Linux services run silently in the background.

These background service processes are often called daemons.

Examples

Daemon names often end with:


d

sshd
systemd
cupsd

12. Practice Exercises

1.

Run:


ps aux

Observe:


2.

Run:


top

Observe:

Exit using:


q

3.

Install and run:


sudo apt install htop

then:


htop

Compare it with top.


4.

Run:


free -h

Record:


5.

Run:


uptime

Observe:


6.

Run:


ping google.com

Stop using:


## CTRL+C

7.

Launch a background job:


sleep 300 &

Then run:


jobs

8.

Run:


pstree

Observe process hierarchy.


13. Key Ideas

Linux systems are collections of running processes.

Processes:

Understanding:

is central to Linux system administration.