norboten · cheat sheet

The limits nobody set, and the numbers everybody misreads — cheat sheet

kernel-performance
# limits
cat /proc/PID/limits                                  # what a process ACTUALLY has
prlimit --pid PID                                     # the same, and --nofile=SOFT:HARD to change it live
systemctl show -p LimitNOFILE -p LimitNOFILESoft UNIT
# [Service] LimitNOFILE=8192   (soft=hard)   LimitNOFILE=8192:524288   (soft:hard)
# sessions: /etc/security/limits.d/*.conf (PAM)   services: the unit (systemd)   never both
ls /proc/PID/fd | wc -l                               # how many it holds now

# memory
free -m                                               # watch "available", not "free"
ps -eo pid,rss,comm --sort=-rss | head                # biggest resident sets
systemctl show -p MemoryPeak -p MemoryCurrent UNIT
# [Service] MemoryMax=300M   → Result: oom-kill instead of a machine-wide OOM
journalctl -k -b | grep -i 'out of memory\|oom-kill'  # CONSTRAINT_MEMCG = a cgroup; CONSTRAINT_NONE = the machine

# CPU and load
cat /proc/loadavg ; nproc                             # load means nothing without the CPU count
vmstat 1 5                                            # r runnable, b blocked, us/sy/id/wa
top -o %CPU ; pidstat 1                               # who

# sysctl
sysctl KEY ; sysctl -w KEY=VALUE                      # now only
echo "KEY = VALUE" > /etc/sysctl.d/90-app.conf ; sysctl --system   # at boot, and now
tuned-adm active ; tuned-adm list                     # tuned sets sysctls too
grep reapply_sysctl /etc/tuned/tuned-main.conf        # 1: sysctl.d files win after the profile

# pressure (if enabled)
ls /proc/pressure || grep -o 'psi=[01]' /proc/cmdline