# Linux Namespace

> A Linux trick that gives programs a private view of the system. Each box is built on it.

**Field:** Infrastructure  
**Category:** Containers  
**Also known as:** Namespaces (Linux), Kernel Namespace, PID Namespace, Network Namespace

## Think of it like

Think of it like a room with the blinds down. You only see what is in your own room.

## Definition

A Linux namespace gives a group of programs their own private view of one part of the system. In a process namespace, the programs see only each other. In a network namespace, they get their own network cards and ports. Linux has eight kinds. They also cover files, users and the computer's name. A container is mostly a program started inside a set of these.

## Example

Lucy runs ps inside a container and sees one process. On the host, the same command lists hundreds.

## Example code

```console
$ docker run --rm alpine ps
PID   USER     TIME  COMMAND
    1 root      0:00 ps
```

In its own process namespace, the box sees one program. That program is number 1.

## Why it matters

Namespaces are why a container cannot see the programs around it. They are the walls of the box.

## Common mistake

Thinking namespaces make a container as safe as a virtual machine. All of them still share one kernel. A flaw in it can reach them all.

## Three principles

- **A private view.** Programs see only their own part.
- **Eight kinds.** Processes, network, files, users and more.
- **One shared kernel.** Walls, not a separate machine.

## Related terms

- [Container](https://learn.benibix.com/term/infrastructure/container)
- [Linux Control Groups (cgroups)](https://learn.benibix.com/term/infrastructure/control-groups)
- [Container Runtime](https://learn.benibix.com/term/infrastructure/container-runtime)
- [Virtual Machine (VM)](https://learn.benibix.com/term/infrastructure/virtual-machine)
- [Kernel](https://learn.benibix.com/term/development/kernel)
- [Process](https://learn.benibix.com/term/development/process)

## Told apart from

- [Linux Namespace vs Kubernetes Namespace](https://learn.benibix.com/compare/linux-namespace-vs-kubernetes-namespace): People think a Kubernetes namespace is a Linux namespace, and it is not. A Linux namespace is a wall inside one computer. It hides the other programs from a container. A Kubernetes namespace is a label. It splits a cluster into groups, such as one per team. By itself, it walls nothing off.

![One host with a shared kernel bar along the bottom. Two containers sit on it, each with its own process list, network and files drawn inside. A dashed fence around each container is labelled with a memory and CPU limit.](https://learn.benibix.com/diagrams/inf4-container-isolation.svg)

---

Source: https://learn.benibix.com/term/infrastructure/linux-namespace
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
