Kahibaro
Discord Login Register

What is a process?

Understanding Processes in Linux

In Linux, almost everything that "runs" is a process. When you execute a command, start a program from your desktop, or run a background service, the system represents that activity internally as one or more processes.

This chapter focuses on what a process is conceptually, without yet going deep into how to view or control them (that’s for later subsections).

Basic Definition

A process is an instance of a running program, together with all the information the operating system needs to manage it.

You can think of it as:

The same program file on disk can correspond to many processes. For example, if you open three terminal windows, you are likely running three separate bash processes, all from the same binary.

Processes vs Programs vs Commands

These three words are often mixed up, but they are not the same:

So:

  1. You type a command (ls).
  2. The shell locates the program (/usr/bin/ls).
  3. The kernel loads the program into memory and creates a process to run it.

When the process exits, the program file still exists; only that running instance ends.

Key Properties of a Process

Each process has a set of key attributes the kernel tracks. Later chapters will show how to see these, but here’s what they represent.

Process ID (PID)

Every process has a unique Process ID (PID), which is a non-negative integer assigned by the kernel.

Example PIDs you might see:

Parent and Child Processes (PPID)

Processes form a tree:

Key ideas:

This parent–child relationship is important for job control, cleanup, and how shells manage pipelines and background jobs.

User and Group Ownership (UID, GID)

Each process runs on behalf of a user:

This affects:

Process State

At any moment, a process is in some state, such as:

You’ll see abbreviations for these states when viewing processes (e.g., R, S, T, Z).

Memory Layout and Address Space

Each process has its own address space in memory:

This separation means:

Environment

When a process starts, it receives a set of environment variables (like PATH, HOME, LANG):

For example, setting LANG=C might affect how sorting or text handling works for a process.

File Descriptors and Resources

A process has a table of file descriptors – small integers that represent open resources:

Standard ones are:

Redirection in the shell (>, <, 2>, etc.) manipulates these for the processes you run.

The kernel also tracks other resource usage per process (CPU time, open files count, etc.).

How Processes Are Created

At a high level, most new processes on Linux are created using two core operations:

For a typical command:

  1. Your shell process calls fork() – now there are two nearly identical shell processes.
  2. The child process calls execve() (or related) to load the program you requested (e.g., /usr/bin/ls).
  3. The child process becomes ls, runs, then exits.
  4. The parent shell waits, then shows a prompt again.

You don’t need to call fork or exec manually when using the shell; they’re done behind the scenes.

Foreground vs Background Processes

From the point of view of a terminal:

The shell’s job-control features manage how your commands become foreground or background processes, which is covered in a later section.

Processes vs Threads (High-Level)

Both processes and threads are ways to run code concurrently:

From the user’s perspective on Linux:

Detailed thread handling is beyond this chapter, but it’s useful to know that not all concurrency is multiple processes.

Why Processes Matter for Everyday Linux Use

Understanding what a process is helps you:

The next chapters in “Working with Processes” will build on this by showing how to see, control, and manage these processes from the command line.

Views: 25

Comments

Please login to add a comment.

Don't have an account? Register now!