When a Linux host feels slow, process-level CPU and memory numbers turn a broad performance complaint into a specific PID, command name, and owner. Checking those fields before restarting services or killing tasks helps separate one busy process from host-wide pressure.
ps reads the process table and reports a point-in-time snapshot. Sorting by %CPU highlights work that has consumed CPU during the current accounting window, while sorting by RSS highlights processes holding resident physical memory.
top samples the same kind of process data repeatedly and is better for short spikes that disappear between ps snapshots. Treat %MEM as a share of visible system memory, read RSS or RES for resident memory, and avoid treating a large VIRT value as physical memory use without confirming the resident column.
$ ps -eo pid,user,stat,comm,pcpu,pmem,rss --sort=-pcpu
PID USER STAT COMMAND %CPU %MEM RSS
2828 root R python3 100 0.0 9352
1 root Ss bash 0.0 0.0 3232
2827 root S python3 0.0 1.5 194336
2830 root R ps 0.0 0.0 3176
The first process rows are the highest sampled CPU users in this ps snapshot. The STAT column shows process state, where R is runnable and D usually means uninterruptible I/O wait.
$ ps -eo pid,user,stat,comm,rss,pmem,pcpu --sort=-rss
PID USER STAT COMMAND RSS %MEM %CPU
2827 root S python3 194336 1.5 0.0
2828 root R python3 9352 0.0 99.5
1 root Ss bash 3232 0.0 0.0
2831 root R ps 3172 0.0 0.0
RSS is shown in KiB by default. Use it with %MEM to find processes holding physical memory instead of only large virtual address space.
$ ps -p 2827 -o pid,user,stat,etime,pcpu,pmem,rss,args
PID USER STAT ELAPSED %CPU %MEM RSS COMMAND
2827 root S 00:02 0.0 1.5 194336 python3 /opt/app/report-worker.py
args shows the command line that started the process. Confirm the target this way before changing priority, sending a signal, or assigning ownership of the issue.
$ top -b -n 1 -o %CPU
top - 20:55:18 up 1 day, 8:59, 0 users, load average: 0.67, 0.34, 0.34
Tasks: 4 total, 2 running, 2 sleeping, 0 stopped, 0 zombie
%Cpu(s): 12.6 us, 0.0 sy, 0.0 ni, 86.2 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 11948.5 total, 7200.7 free, 1118.0 used, 3877.1 buff/cache
MiB Swap: 4096.0 total, 4096.0 free, 0.0 used. 10830.4 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2828 root 20 0 15704 9352 5244 R 90.9 0.1 0:02.22 python3
1 root 20 0 5744 3232 2964 S 0.0 0.0 0:00.00 bash
2827 root 20 0 200628 194336 5428 S 0.0 1.6 0:00.00 python3
2833 root 20 0 7560 4912 2400 R 0.0 0.0 0:00.00 top
-b -n 1 makes top print one batch-mode sample and exit. In interactive top, press P to sort by CPU.
$ top -b -n 1 -o %MEM
top - 20:55:18 up 1 day, 8:59, 0 users, load average: 0.67, 0.34, 0.34
Tasks: 4 total, 2 running, 2 sleeping, 0 stopped, 0 zombie
%Cpu(s): 12.4 us, 0.0 sy, 0.0 ni, 87.6 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 11948.5 total, 7200.7 free, 1118.0 used, 3877.1 buff/cache
MiB Swap: 4096.0 total, 4096.0 free, 0.0 used. 10830.4 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2827 root 20 0 200628 194336 5428 S 0.0 1.6 0:00.00 python3
2828 root 20 0 15704 9352 5244 R 100.0 0.1 0:02.44 python3
2834 root 20 0 7236 4304 2392 R 0.0 0.0 0:00.00 top
1 root 20 0 5744 3232 2964 S 0.0 0.0 0:00.00 bash
RES is the resident memory column in top. In interactive top, press M to sort by memory.
If the same PID stays at the top, inspect the owning service or application logs before taking action. For a non-critical CPU-heavy task, adjust priority before killing it; for a stuck or runaway process, signal only the confirmed target.
Related: How to change process priority in Linux
Related: How to kill a process in Linux