RousselTMLEARNING

Article · Linux administration: from discovery to expertise

Processes, memory and performance

1. Processes #

What is running and how to control it.

Listing #

ps aux --sort=-%cpu | head       # plus gros consommateurs CPU
ps aux --sort=-%mem | head
ps -ef --forest                 # arbre parent/enfant
pgrep -a nginx ; pidof sshd
top   # P : tri CPU, M : tri mémoire, 1 : par cœur, k : tuer
htop  # version interactive et colorée

States #

Process states
Many processes in D state drive the load up without consuming CPU.
StateMeaning
Rrunning or ready
Ssleeping, waiting for an event (normal case)
Duninterruptible I/O wait (disk, NFS): cannot be killed
Zzombie: finished, not yet reaped by its parent
Tstopped (Ctrl+Z)

Signals #

kill -15 1234     # SIGTERM : demande d'arrêt propre (défaut)
kill -9 1234      # SIGKILL : arrêt immédiat, sans nettoyage
kill -HUP 1234    # SIGHUP : souvent « relire la configuration »
pkill -u bob      # tous les processus de bob
killall -s TERM python3
Good practice: Always send SIGTERM first and wait a few seconds: SIGKILL prevents the application from closing its files and connections cleanly.

Priorities and background #

nice -n 10 tar -czf backup.tgz /srv   # lancer avec une priorité basse
renice +5 -p 1234
ionice -c3 rsync -a /src /dst          # E/S seulement quand le disque est libre
commande &   ; jobs ; fg %1 ; bg %1     # tâches du shell
nohup ./long.sh > long.log 2>&1 &      # survivre à la déconnexion
tmux new -s maintenance                # session détachable (Ctrl+B D, puis tmux attach)

2. CPU, memory and disks #

Reading the right indicators.

Load #

uptime    # load average 1, 5 et 15 min
nproc     # nombre de cœurs

The load counts processes running or waiting (including in D state). It is interpreted relative to the number of cores: 4 on 4 cores = full; 12 on 4 cores = saturation. A high load with little CPU usage often indicates disk waits.

Memory #

Memory breakdown
The cache is given back immediately to applications that need it.
free -h

Look at the available column, not free: Linux uses free memory as disk cache (buff/cache), which can be reclaimed immediately. A server with little « free » but plenty of « available » is fine.

When memory really runs out, the kernel triggers the OOM killer, which kills the most memory-hungry process:

journalctl -k | grep -i 'out of memory'
dmesg -T | grep -i oom
cat /proc/1234/status | grep VmRSS

vmstat and iostat #

vmstat output
Swap, disk wait and blocked processes: the server is short of memory.
vmstat 1                 # r, b, si/so, wa
iostat -xz 1             # %util et await par disque (paquet sysstat)
mpstat -P ALL 1          # CPU par cœur
pidstat 1                # consommation par processus
sar -u -f /var/log/sysstat/sa26   # historique (sysstat)

3. Diagnosing a process #

Seeing what it really does.

lsof, strace and /proc #

sudo lsof -p 1234             # fichiers et sockets ouverts
sudo lsof -i :8080            # qui utilise ce port ?
sudo lsof /var/log/app.log
sudo strace -p 1234 -f -e trace=network,file   # appels système en direct
sudo strace -c -p 1234        # statistiques des appels (Ctrl+C)
cat /proc/1234/cmdline | tr '\0' ' '
ls -l /proc/1234/cwd /proc/1234/exe
cat /proc/1234/limits         # limites (fichiers ouverts...)
ulimit -n

Limiting resources #

systemd places each service in a cgroup: it can be limited without touching the application.

sudo systemctl set-property app.service MemoryMax=1G CPUQuota=150%
systemd-cgtop                  # consommation par service

4. A method #

Not searching at random.

USE #

USE method
Reviewing each resource avoids forgetting the disk or the network.
  1. uptime: is the load rising?
  2. dmesg -T | tail: kernel errors, OOM, disk?
  3. vmstat 1: run queue, swap, I/O wait
  4. mpstat -P ALL 1: a saturated core?
  5. iostat -xz 1: saturated disk?
  6. free -h: available memory
  7. ss -s, ip -s link: connections, network errors
  8. top / pidstat: which process?
Good to know: This « first 60 seconds » checklist comes from Netflix's performance team: it is enough to orient most diagnoses.

📄 Processes, memory and performance: monitoring and troubleshooting a Linux server →

My progress

  • ⏱ Estimated time : ≈ 9 min

Sign in to track your progress and take notes. Sign in

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

Recommended Articles

Packages, systemd services, logs and scheduled tasks

Install and update software with apt and dnf, manage services with systemctl, write a systemd uni...

Bash scripts for administrators: writing robust scripts

Automate Linux administration with Bash: variables and quoting, conditions, loops, functions, exi...

Services, scheduled tasks, event logs and performance

Control Windows services and their recovery, automate with Task Scheduler, use event logs with Ge...

Backup, Hyper-V and Windows troubleshooting

Back up and restore with Windows Server Backup (including system state and Active Directory), vir...

Windows networking: IP, DNS, DHCP, firewall and remote access

Configure and troubleshoot Windows networking with PowerShell, deploy a DHCP server, master Windo...

Windows administration best practices

The production checklist for Windows and Windows Server: installation, identity and Active Direct...

Users, groups, NTFS permissions and SMB shares

Manage local accounts and groups, understand UAC, apply NTFS permissions with inheritance, create...

Measuring DevOps performance: DORA metrics, SPACE and continuous improvement

Measure and improve delivery performance: the DORA metrics (deployment frequency, lead time, chan...

Windows and Windows Server: versions, editions and architecture

Discover the Windows ecosystem for administrators: Windows 11 and Windows Server 2025, editions a...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!