Skip to content

Linux & shell: Processes

6 Linux & shell commands: Processes. Click a command to see what each part does.

Index
6 items
Click a command to see what each part does.

Processes6

  • ps aux | grep <name>Find a process by name

    What each part does

    1. pssnapshot of current processes
    2. auxBSD-style options (no dash): a = all users, u = user-oriented columns (USER, %CPU, %MEM…), x = include processes without a terminal
    3. |pipe the process list into grep
    4. grep <name>keep only lines containing <name>

    Tip The grep line itself matches too. Use grep "[n]ginx" (brackets on one letter) or pgrep -a <name>.

  • ps aux --sort=-%mem | headTop 10 processes by memory

    What each part does

    1. ps auxall processes, user-oriented columns
    2. --sort=-%memsort by memory share; the leading "-" means descending
    3. | headkeep the first 10 lines (header + top 9)
  • ps -eo pid,user,%cpu,%mem,comm --sort=-%cpu | head -n 15Custom columns sorted by CPU

    What each part does

    1. -eselect every process
    2. -o pid,user,%cpu,%mem,commchoose the output columns: PID, owner, CPU %, memory %, executable name
    3. --sort=-%cpuhighest CPU first
    4. head -n 15first 15 lines
  • top -b -n 1 | head -n 20One-shot top output (for logs or scripts)

    What each part does

    1. toplive process viewer
    2. -bbatch mode: plain text, no interactive screen (works in pipes)
    3. -n 1stop after one refresh
    4. head -n 20summary lines plus the top processes
  • kill <pid>; sleep 5; kill -9 <pid>Stop a process gracefully, then forcefullyCaution

    What each part does

    1. kill <pid>send SIGTERM (15): asks the process to exit and clean up
    2. sleep 5give it time to shut down
    3. kill -9 <pid>send SIGKILL: cannot be caught, ends it immediately (no cleanup)
  • free -hMemory usage in human units

    What each part does

    1. freeshow RAM and swap usage
    2. -hhuman-readable units (Mi, Gi). Look at the "available" column, not "free"

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…