Pcornel
Linux

Processes

Cheat sheet · https://pcornel.dk/topic.php?topic=2713

Back to the Topic

Answer

A process is a running program with its own PID, memory, open files, user and environment. Processes are created by a parent (fork/exec), run, may create children, and exit with a status.

Remember

Find the process first, then its owner (systemd unit, shell, cron) — restart it through that owner, not by killing it. A service may have several processes; systemctl status shows its cgroup.

First checks

  • ps -eo pid,ppid,user,stat,%cpu,%mem,etime,cmd --sort=-%cpu | head — processes by CPU with parent and state
  • pstree -p <pid> — process tree
  • top / htop — live CPU and memory
  • cat /proc/<pid>/status — state, threads and memory of one process

Commands

ps
Capture a point-in-time process listing with selected identity, state and resource fields.
top
Interactively sample processes, CPU, memory and load for live resource triage.
htop
Interactively inspect and manage processes with a curses-based resource view.
pgrep
Return process identifiers that match names or other process-selection criteria.
pkill
Send a signal to processes selected by name or other matching criteria.
kill
Send a selected signal to one or more process identifiers.
killall
Send a signal to processes selected primarily by executable name.
nice
Start a command with an adjusted CPU scheduling niceness value.
renice
Change the niceness of an already running process, process group or user workload.
jobs
List jobs tracked by the current interactive shell and their job-control state.
nohup
Run a command with hangup handling and output redirection suitable for session detachment.

Verify in this order

parent forks → child execs the program → runs as a user with limits → exits with a status → parent reaps it

Where it usually breaks

First mismatch in hardware/kernel capability → scheduler/mm/device → cgroup/namespace → process/thread → service/runtime → workload behavior/counters; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2713

Confirmation

Confirm action

Continue?