Cheat SheetsLinux Internals Pro Reference

Professional Quick Reference: Linux Internals (MOD-LINUX-INT)

Core Files & Environment Limits

ComponentTarget Path / CommandProduction Context
Global Memory Stats/proc/meminfoAuthoritative source for kernel memory allocation
Cgroups v2 Root/sys/fs/cgroup/Unified hierarchy for resource accounting
Process FD Table/proc/<PID>/fd/Symlinks to open file descriptors for <PID>
Kernel Ring Bufferdmesg -TCritical for diagnosing OOM kills or hardware faults
Check Cgroups v2stat -fc %T /sys/fs/cgroup/Validates cgroup2fs presence vs legacy tmpfs

Advanced Debugging & Tracing

OperationCommand SyntaxProduction Use Case
Trace Syscallsstrace -p <PID> -fAttach to running process & follow child threads
Trace Syscall Countsstrace -c -p <PID>Profile system calls and time spent per call
Trace Dynamic Libsltrace -p <PID>Intercept library calls made by an active binary
Check Lib Depsldd /path/to/binaryVerify presence of required .so shared libraries
List Open FDslsof -p <PID>Inspect all open files/sockets held by process
Find Port Ownerlsof -i :<PORT>Identify which process PID is bound to a port

Cgroups v2 Resource Limiting

OperationCommand SyntaxNotes
Create Groupsudo mkdir -p /sys/fs/cgroup/<name>Instantly populates controller files
Set RAM Maxsudo sh -c "echo <BYTES> > /sys/fs/cgroup/<name>/memory.max"Triggers OOM Killer if limit is exceeded
Set CPU Limitsudo sh -c "echo <MAX> <PERIOD> > /sys/fs/cgroup/<name>/cpu.max"Ex: 50000 100000 = 50% of 1 CPU core
Attach PIDsudo sh -c "echo <PID> > /sys/fs/cgroup/<name>/cgroup.procs"Process immediately respects applied limits
Verify PIDscat /sys/fs/cgroup/<name>/cgroup.procsView processes trapped in the cgroup

[!WARNING] Cgroup Deletion: You cannot remove a cgroup (rmdir) if processes are still attached. You must first kill the PIDs or migrate them to the root (echo <PID> > /sys/fs/cgroup/cgroup.procs).

Namespace Isolation (Container Primitives)

Namespaceunshare flagIsolation Scope
PID--pid --mount-procProcess trees (PID 1 mapping)
UTS--utsHostname and NIS domain name
Network--netInterfaces, routing tables, iptables
Mount--mountMount points (/ filesystem)
User--userUIDs and GIDs

Scaffold an Isolated Container

# Launch a fully isolated bash session from scratch
sudo unshare --fork --pid --mount-proc --uts --net /bin/bash

OOM (Out Of Memory) Killer Operations

OperationCommand Syntax
Check Active OOM Scorecat /proc/<PID>/oom_score
Adjust OOM Prioritysudo sh -c "echo <SCORE> > /proc/<PID>/oom_score_adj"
Search OOM Kill Logsdmesg -T | grep -i 'killed process'

[!CAUTION] OOM Immunity Risk: Setting an oom_score_adj of -1000 renders a process completely immune to the OOM killer. Use exclusively for critical cluster agents (e.g., kubelet, sshd), otherwise rogue memory leaks will completely crash the kernel.