StudyLover
  • Home
  • Study Zone
  • Profiles
  • Typing Tutor
  • Contact us
  • Sign in
StudyLover Monitoring: top
Download
  1. Linux
Monitoring : Monitoring: ps
Linux

top — the real-time system monitor you’ll use to see “what’s eating CPU/RAM”.


What top shows (at a glance)

When you run top, you’ll see:

Header (system summary):

·         uptime & load average – overall system load (last 1/5/15 minutes).

·         Tasks – total/running/sleeping/zombie processes.

·         CPU line – time spent: us(user), sy(system), ni(nice), id(idle), wa(I/O wait), hi/si (hw/sw interrupts), st(steal in VMs).

·         Mem/Swap – total, used, free, buffers/cache.

Process table (per process):
Common columns:

·         PID – process ID

·         USER – owner

·         PR/NI – priority/nice

·         VIRT/RES/SHR – virtual/physical/shared memory

·         S – state (R running, S sleeping, D uninterruptible, Z zombie, T stopped)

·         %CPU / %MEM – usage

·         TIME+ – total CPU time

·         COMMAND – program/command line (c toggles full cmdline)

Quit anytime with q.


Most useful interactive keys (press inside top)

·         1 – show per-CPU/core usage

·         P – sort by CPU% (default on many systems)

·         M – sort by memory

·         T – sort by time

·         N – sort by PID; R – reverse sort

·         k – kill a process (enter PID, then signal; default 15)

·         r – renice (change priority) a process

·         u – filter by user (show only one user’s processes)

·         o / O – add/change a filter (e.g., COMMAND=python)

·         n – set number of displayed tasks/lines

·         H – toggle threads view

·         c – toggle show command vs program name

·         h or ? – help

·         d – set refresh delay (seconds)

·         b – bold highlight; x/y – highlight sort column/task


Handy ways to start top (non-interactive options)

top -d 1                  # refresh every 1s

top -u yourname           # only your processes

top -p 1234               # only PID 1234

top -b -n 1               # batch mode, run once (great for scripts/logs)

Batch example to save a snapshot:

top -b -n 1 | tee top_snapshot.txt


Typical student tasks (quick recipes)

Find what’s hogging CPU/RAM

·         Run top, press P (CPU) or M (memory).

·         Press 1 to see which core is busy.

Kill a runaway process

·         In top, note its PID, press k, enter PID, then 15 (TERM).

·         If it ignores TERM, try 9 (KILL) as last resort.

Lower a process’s priority

·         Press r, enter PID, then a higher nice value (e.g., 10 to make it nicer/less CPU-greedy).

See only Python jobs by you

·         Start with top -u yourname, then o and type COMMAND=python.


Reading the CPU & load lines (fast intuition)

·         Load average roughly equals “runnable queue length.”
If load
≫ number of CPU cores for a while → CPU-bound or heavy I/O wait.

·         wa (I/O wait) high → disks are the bottleneck; check iostat/iotop.

·         Memory used high + swap activity → RAM pressure; find big %MEM in table.


Common pitfalls

·         Values jump around quickly: press d and set delay to 2 for calmer updates.

·         Remote SSH sessions: reduce refresh frequency or use batch mode for logs.

·         Don’t kill random PIDs on shared systems—confirm the process first (COMMAND, USER).


Mini-lab (10–15 min)

# 1) Watch per-core usage:

top           # then press 1

 
# 2) Generate CPU load in another terminal:

yes > /dev/null &    # start; note its PID in 'top'

# back in top: press P to sort, then k -> PID -> 15 to stop it

# or outside: kill %1

 
# 3) Batch snapshot for a report:

top -b -n 1 > ~/top_once.txt && tail -n 15 ~/top_once.txt


Exam-ready bullets

·         top = real-time process & resource monitor; quit q.

·         Header shows load, CPU split (us/sy/id/wa/…), Mem/Swap; table shows PID/USER/%CPU/%MEM/TIME+/COMMAND.

·         Keys: P/M/T/N/R/1/u/k/r/c/H/d/h.

·         Start options: -u user, -p PID, -d delay, -b -n (batch/count).

·         Use k to kill, r to renice; diagnose high load/wa/swap to find bottlenecks.

Want a one-page monitoring cheat sheet with top, htop, free, df/du, iostat/iotop, and ss/iftop together? I can format it for print.

 

Monitoring Monitoring: ps
Our Products & Services
  • Home
Connect with us
  • Contact us
  • +91 82955 87844
  • Rk6yadav@gmail.com

StudyLover - About us

The Best knowledge for Best people.

Copyright © StudyLover
Powered by Odoo - Create a free website