linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Introduction
  • Lessons
  • How it works
  • Simulator
  • Knowledge base
  • Interview prep
Index
Categories
All entries
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
home/linux/kb/Processes & resources/process-and-pid

kb/processes ── Processes & resources ── beginner

Process and PID

A process is a running program with its own PID, memory, open descriptors, and UID. Every process forms a tree rooted at init (PID 1).

view as markdownaka: process, pid, ppid

What a process is

A process is a running instance of a program. It has:

  • PID (Process ID): a unique numeric identifier
  • PPID (Parent PID): who spawned it
  • UID/GID: whose identity it runs under (see file-permissions)
  • Virtual address space: heap, stack, mmaps, shared libraries
  • Open file descriptors (/proc/<pid>/fd/*)
  • Current working directory (cwd)
  • Control group (cgroups) and a set of namespaces that decide what it sees

fork + exec

A new process in Linux is always created by one of these pairs of system calls:

  • fork(): clone the current process. You get a child with the same code and state but a new PID
  • exec*(): replace the code and data in the current process with the contents of a binary; the PID stays the same

This is how the shell launches a command: fork() → the child does exec("/bin/ls"). The parent waits through wait().

The process tree

Every process descends from one: PID 1 (init, which on modern systems is systemd). If a parent dies before its child, the child is reparented to PID 1.

systemd
 ├─ sshd
 │   └─ sshd: alice@pts/0
 │       └─ bash
 │           └─ vim
 ├─ docker
 └─ ...

/proc/<pid>: the anatomy of a process

In Linux every live process is a directory /proc/<pid>/:

  • cmdline: what was in argv
  • exe → symlink to the binary
  • cwd → symlink to the CWD
  • fd/: all open file descriptors (as symbolic-link entries to their targets)
  • status: a card of metadata (UID, threads, memory)
  • cgroup: which cgroup the process is in
  • ns/: which namespaces it sees

Process states

  • R (Running/Runnable): on the CPU or in the CPU run queue
  • S (Sleeping): waiting for an event (interruptible: a signal can wake it)
  • D (Uninterruptible Sleep): waiting for I/O in kernel mode, cannot be interrupted. A high share of D usually means disk or NFS trouble, and it pulls load-average up
  • Z (Zombie): finished, but the parent has not called wait() yet. It holds a PID but no RAM
  • T (Stopped): suspended by signal SIGSTOP or Ctrl+Z

§ команды

bash
ps -ef | head

Every process in the system with PID, PPID, UID, and command

bash
ps -p $$ -o pid,ppid,comm,state

Information about the current shell ($$ = the shell's PID)

bash
pstree -p

The process tree with PIDs

bash
cat /proc/$$/status | head -10

The current shell's card from /proc

bash
ls -l /proc/self/fd/

Open file descriptors of the process (`self` always points at the reader)

§ см. также

  • signalsSignals (SIGTERM, SIGKILL, SIGHUP)A signal is an asynchronous notification to a process from the kernel or another process. TERM asks it to quit, KILL kills it now, HUP reloads config.
  • cmd-psps: process snapshotps prints a snapshot of processes at the moment it runs. Two dialects: BSD (`aux`, no dash) and UNIX (`-ef`, with dash). `-o` specifies columns. For continuous monitoring, use [[cmd-htop|htop]].
  • cmd-htophtop: interactive process monitorhtop is an interactive TUI process monitor. F-keys: F3 search, F4 filter, F5 tree, F6 sort, F9 kill. Color meters at the top, process list below. It replaces top wherever it is available.
  • cgroupscgroups (v2)cgroups v2 is a hierarchical virtual FS under `/sys/fs/cgroup` that the kernel uses to limit CPU, memory, and I/O for processes. Docker, k8s, and systemd write here.
  • namespacesLinux namespacesNamespaces are a kernel mechanism that gives a process its own isolated view of a resource (network, mount points, PID, UID, IPC, hostname, time). Every container is built on them.
  • cmd-stracestrace: what syscalls a process makes`strace` shows in real time which system calls a process makes and with what arguments. The primary tool when a process goes silent.

§ упоминается в уроках

  • ›advanced-02-cgroups-v2
  • ›advanced-06-ebpf-trace
  • ›advanced-07-perf-and-flame
  • ›beginner-01-filesystem
  • ›beginner-02-directory-tree
  • ›beginner-04-pipes-and-redirects
  • ›beginner-05-permissions
  • ›beginner-06-users-and-groups
  • ›beginner-07-processes-and-signals
  • ›beginner-09-environment-and-shell
  • ›beginner-12-shell-scripting
  • ›intermediate-07-debugging-with-proc
Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies