Essential "kill" for linux analysis, diagnosis, and optimization"
1. toptop-02:06:59 up 4 days, 2 users, load average: 0.00, 0.00, 0.00 Tasks: 62 total, 1 running, 61 sleeping, 0 stopped, 0 zombieCpu (s): 0.2% us, 0.3% sy, 0.0% ni, 97.8% id, 1.7% wa, 0.0% hi, 0.0% siMem: 515144 k total, 317624 k used, 197520 k free, 66068 k buffersSwap: 1048120 k total, 12 k used, 1048108 k free, 179632 k cachedPID user pr ni virt res shr s % CPU % mem time + COMMAND13737 root 17 0 17 60 896 1540 R 0.7 0.2. 05 top238 root 5-10 0 0 S 0.3 0.0. 56 reiserfs/01 root 16 0 588 240 444 S 0.0 0: 05. 70 init2 root RT 0 0 0 S 0.0 0.0. 00 migration/03 root 34 19 0 0 S 0.0 0.0. 00 ksoftirqd/04 root RT 0 0 0 0 S 0.0 0.0. 00 migration/15 root 34 19 0 0 S 0.0 0.0. 00 ksoftirqd/16 root 5-10 0 0 0 S 0.0 0.0. 02 events/0 output column description: PID: Process identification. USE R: Name of the user who owns (and perhaps started) the process. PRI: Priority of the process. (See 1.1.4, "Process priority and nice level" on page 5 for details .) SIZE: Amount of memory (code + data + stack) used by the process in kilobytes. RSS: Amount of physical RAM used, in kilobytes. SHARE: Amount of memory shared with other processes, in kilobytes. STAT: State of the process: S = sleeping, R = running, T = stop Ped or traced, D = interruptible sleep, Z = zombie. % CPU: Share of the CPU usage (since the last screen update ). % MEM: Share of physical memory. TIME: Total CPU time used by the process (since it was started ). COMMAND: Command line used to start the task (including parameters ). useful hotkeys: t: Displays summary information off and on. m: Displays memory information off and on. a: Sorts the display by top consumers of v Arious system resources. useful for quick identification of performance-hungry tasks on a system. f: Enters an interactive configuration screen for top. helpful for setting up top for a specific task. o: Enables you to interactively select the ordering within top. r: Issues renice command. k: Issues kill command. O or F: enters an interactive configuration screen for processes order. h: displays help scre En.2, vmstatprocs ----------- memory ---------- --- swap -- ----- io ---- system -- ---- cpu ---- r B swpd free buff cache si so bi bo in cs us sy id wa0 1 0 1742264 112116 0 0 1 4 3 3 0 0 99 00 1 0 1742072 112208 0 0 0 1999772 2536 1258 0 1 75 1146 1 0 240 1741880 0 0 112260 1999720 2668 1 75 1235 1 0 1741560 112308 1999932 0 0 2930 1240 1015 0 1 75 241 1 0 1741304 112344 0 0 0 2980 1238 925 0 1 75 240 1 0 1741176 112384 0 0 0 2000636 2968 1233 0 1 75 929 1 0 240 1741304 112420 0 0 2000600 3024 0 1247 0 1 1 75 24 output column description: process (procs) r: The number of processes waiting for runtime B: The number of processes in uninterruptable sleepMemory swpd: The amount of virtual memory used (KB) free: the amount of idle memory (KB) buff: The amount of memory used as buffers (KB) Cache: The amount of memory used as cache (KB) Swap si: Amount of memory swapped from the disk (KBps) so: Amount of memory swapped to the disk (KBps) IO bi: blocks sent to a block device (blocks/s) bo: Blocks received ed from a block device (blocks/s) System in: The number of interrupts per second, including the clock cs: the number of context switches per secondCPU (% of total CPU time) us: Time spent Running non-kernel code (user time, including nice time ). sy: Time spent running kernel code (system time ). id: Time spent idle. prior to Linux 2.5.41, this has ded I/O-wait time. wa: Time spent waiting for IO. prior to Linux 2.5.41, this appeared as zero. useful command line parameters:-m: displays the memory utilization of the kernel (slabs)-a: provides information about active and inactive memory pages-n: displays onl Y one header line, useful if running vmstat in sampling mode and piping the output to a file. (For example, root # vmstat-n 2 10 generates vmstat 10 times with a sampling rate of two seconds .) when used with the-p {partition} flag, vmstat also provides I/O statistics.3, uptime10: 12: 37 up 244 days, 26 min, 1 user, load average: 10.92, 23.68, 23.64 note: The uptime command can be used to see how long Server has been running and how many users are logged on, as well as for a quick overview of the average load of the server. the system load average is displayed for the past 1 minute, 5 minute, and 15 minute intervals.4, ps useful Command Options:-e: All processes. identical to-A-l: Show long format-F: Extra full mode-H: Forest-L: Show threads, possibly with LWP and NLWP columns-m: show threads after processesroot # ps- ElFLF s uid pid ppid lwp c nlwp pri ni addr sz wchan rss psr stime tty time limit 4 S root 1 0 1 0 1 76 0-457-552 0 Mar08? 00:00:01 init [3] 1 S root 2 1 2 0 1-40--0 migrat 0 0 Mar08? 00:00:36 [migration/0] 1 S root 3 1 3 0 1 94 19-0 ksofti 0 0 Mar08? 00:00:00 [ksoftirqd/0] root # ps-eLF | grep-E "LWP |/usr/sbin/httpd" uid pid ppid lwp c nlwp sz rss srs stime tty time CMDroot 4504 1 4504 0 1 4313 8600 2? 00:00:00/usr/sbin/httpdapache 4507 4504 4507 0 1 4313 4236 1? 00:00:00/usr/sbin/httpdapache 4508 4504 4508 0 1 4313 4228 1? 00:00:00/usr/sbin/httpd output column description: F: Process flagS: State of the process: S = sleeping, R = running, T = stopped or traced, D = interruptable sleep, Z = zombie. UID: Name of the user who owns (and perhaps started) the process. PID: Process ID numberPPID: Parent process ID numberLWP: LWP (light weight process, or thread) ID of the lwp being reported. c: Integer value of the processor utilization percentage. (CPU usage) NLWP: Number of lwps (threads) in the process. (alias thcount ). PRI: Priority of the process. NI: Niceness level (whether the process tries to be nice by adjusting the priority by the number given; see below for details ). ADDR: Process Address space (not displayed) SZ: Amount of memory (code + data + stack) used by the process in kilobytes. WCHAN: Name of the kernel function in which the process is sleeping, a "-" I F the process is running, or a "*" if the process is multi-threaded and ps is not displaying threads. RSS: Resident set size, the non-swapped physical memory that a task has used (in kiloBytes ). PSR: Processor that process is currently assigned. STIME: Time the command started. TTY: TerminalTIME: Total CPU time used by the process (since it was started ). CMD: Command line used to start the task (including Parameters ). 5. free command parameters:-B,-k,-m,-g: Display values in bytes, kilobytes, megabytes, and gigabytes-l: distinguishes between low and high memory-c <count>: Displays the free output <count> number of times [root @ edam ~] # Free-l total used free shared buffers cachedMem: 4154484 2381500 1772984 0 108256 1974344Low: 877828 199436 678392 High: 3276656 2182064 1094592-/+ buffers/cache: 298900 3855584 Swap: 4194296 0 4194296