Hosting Operations
Read-only, can be slowFind the Processes Eating Memory
The server is slow, swap may be active, or processes are getting killed, and you need to see which processes have the largest resident memory footprint.
Command
ps -eo pid,ppid,stat,pcpu,pmem,rss,comm,args --sort=-pmem | head -n 10
Before you run this
System impact: Read-only. Can create load on large logs, directories, filesystems, or process tables.
When not to use it: Do not use it as the whole memory diagnosis. Pair it with `free -h`, swap activity, and recent service logs before restarting anything.
Expected output
A process list sorted by memory percentage, with RSS shown so resident memory stands out from vague percent-only readings.
System impact
Read-only, can be slow. Nothing changes. The command reads process metadata and sorts by memory percentage; it may reveal process arguments, so avoid sharing raw output carelessly.
Scope this to the smallest useful path or service on busy systems.
Recovery / rollback: no state is changed.
When to use it
Use after checking overall memory pressure, or when one service is suspected of leaking memory.
When not to use it
Do not use it as the whole memory diagnosis. Pair it with `free -h`, swap activity, and recent service logs before restarting anything.
Watch this command run
Command transcript
This sanitized transcript shows the commands and output shape without exposing host details.
$ free -h
total used free shared buff/cache available
Mem: 1.9Gi 1.4Gi 94Mi 18Mi 410Mi 312Mi
Swap: 2.0Gi 620Mi 1.4Gi
$ ps -eo pid,ppid,stat,pcpu,pmem,rss,comm,args --sort=-pmem | head -n 10
PID PPID STAT %CPU %MEM RSS COMMAND COMMAND
2011 1 S 4.5 37.9 776M postgres postgres: main
1842 1 R 86.4 14.2 291M app-worker /srv/app/worker --jobs
1907 1 S 12.8 3.1 63M nginx nginx: worker process
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
free -hps -eo pid,ppid,stat,pcpu,pmem,rss,comm,args --sort=-pmem | head -n 10
next steps
Related commands
Find the Processes Burning CPU
A server feels slow, but you need proof before restarting anything.
ps -eo pid,ppid,stat,pcpu,pmem,comm,args --sort=-pcpu | head -n 10
Find the Processes Using Memory
The server felt slow. Memory pressure was the first thing to rule out.
ps -eo pid,comm,%mem,%cpu --sort=-%mem | head
Find Top 404 URLs
The missing file was not random. The access log had a pattern.
awk '$9==404 {print $7}' /var/log/nginx/access.log | sort | uniq -c | sort -nr | head
Find the Largest CI Artifacts
A bloated artifact can explain a slow or failed pipeline.
find artifacts -type f -printf '%s %p\n' | sort -nr | head -10
Find Directories Burning Inodes
Inode cleanup starts by finding the directory with too many files.
find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%h\n' | sort | uniq -c | sort -nr | head
Study mapping
Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.
Useful for
- LPIC-1 style command-line practice
- LFCS style performance tasks
- Linux+ style troubleshooting review
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.