Echoshell
  • Selfservice book
  • MacBook Setup
  • Linux SystemAdmin
    • Linux useful commands
    • Analyze tools
      • Hardware overview
      • Vmstat
      • Top
      • Sar
      • ltrace
      • strace
      • Netstat/SS
      • lsof
      • iostat
      • iotop
    • Performance Tuning
      • CPU
      • Momory
      • Disk/Storage
      • Network
      • Process
  • SRE vs DevOps
    • Ansible
    • Git
    • Jenkins
    • HashiCorp-Terraform
      • Terraform VS. CloudFormation
      • Main elements
        • Provider
        • State Storage and Locking
        • Backends
      • Basic Elements
        • Install
        • Resource
        • Data
        • Output
        • Locals
      • Commands
        • terraform plan
        • terraform apply
        • terraform import
    • HashiCorp-Vault
    • HashiCorp-Consul
    • CI/CD
      • GoCD
  • Automation/Script Language
    • Shell&Bash
      • Useful links
    • Python
      • 基础
        • py2 vs py3
        • 字符编码
        • 输入和输出
      • 数据类型Data Types
        • 字符串String
        • 列表List
        • 元组Tuple
        • 字典Dict
        • 集合Set
      • 函数Function
        • 定义函数
        • 函数参数
      • 函数式编程
        • 匿名函数lamba
        • map/reduce/filter
        • 闭包
        • 装饰器
      • 类Class
        • 类和实例
        • 继承和多态
        • 类方法和静态方法
        • 定制类和魔法方法
        • 元类-陌生的 metaclass
      • 高级特性
        • 迭代器iterator
        • 生成器generator
        • 上下文管理
      • 文件和目录
        • 读写文本文件
        • os 模块
      • 进程、线程和协程
        • 进程
        • 线程
        • ThreadLocal
        • 协程
      • 异常处理Exception
      • 正则表达式Regular-Expressions
        • re 模块
      • 标准模块
        • datetime
        • argparse
      • 第三方模块Three Parts
        • Click
        • JIRA
        • Email
        • Jenkins
      • 系统相关模块System modules
        • Subprocess
        • shutil
  • Learning notes from organization
  • IT Tech Team Leader/Senior System administrator
    • Helpdesk
    • Windows Servers
      • Radius Server
      • NFS
      • Munki
      • 802.1X
    • Networks
  • Personal views and ideas from my careen path
    • Team management
    • Career path change from IT to devops
Powered by GitBook
On this page

Was this helpful?

  1. Linux SystemAdmin
  2. Analyze tools

Top

Usage

  • f - customize top show options

  • 'N' - to sort the list by process id

  • 'P' - to sort the process list by cpu usage.

  • 'T' - to sort by the running time.

  • 'Mm' - to sort by the memory

  • 1 - show all cpus usage

  • -d/d - delay seconds top -d 2

  • -c/c - show it will display absolute path of running process.

  • -u - top -u mysql

  • save top results top -n 1 -b > top-output.txt

  • -r/r - renice pid

Fields Management for window 1:Def, whose current sort field is %CPU
   Navigate with Up/Dn, Right selects for move then <Enter> or Left commits,
   'd' or <Space> toggles display, 's' sets sort.  Use 'q' or <Esc> to end!

* PID     = Process Id      TTY     = Controlling T   vMj     = Major Faults
* USER    = Effective Use   TPGID   = Tty Process G   vMn     = Minor Faults
* PR      = Priority        SID     = Session Id      USED    = Res+Swap Size
* NI      = Nice Value      nTH     = Number of Thr   nsIPC   = IPC namespace
* VIRT    = Virtual Image   P       = Last Used Cpu   nsMNT   = MNT namespace
* RES     = Resident Size   TIME    = CPU Time        nsNET   = NET namespace
* SHR     = Shared Memory   SWAP    = Swapped Size    nsPID   = PID namespace
* S       = Process Statu   CODE    = Code Size (Ki   nsUSER  = USER namespac
* %CPU    = CPU Usage       DATA    = Data+Stack (K   nsUTS   = UTS namespace
* %MEM    = Memory Usage    nMaj    = Major Page Fa   LXC     = LXC container
* TIME+   = CPU Time, hun   nMin    = Minor Page Fa   RSan    = RES Anonymous
* COMMAND = Command Name/   nDRT    = Dirty Pages C   RSfd    = RES File-base
  PPID    = Parent Proces   WCHAN   = Sleeping in F   RSlk    = RES Locked (K
  UID     = Effective Use   Flags   = Task Flags <s   RSsh    = RES Shared (K
  RUID    = Real User Id    CGROUPS = Control Group   CGNAME  = Control Group
  RUSER   = Real User Nam   SUPGIDS = Supp Groups I
  SUID    = Saved User Id   SUPGRPS = Supp Groups N
  SUSER   = Saved User Na   TGID    = Thread Group
  GID     = Group Id        OOMa    = OOMEM Adjustm
  GROUP   = Group Name      OOMs    = OOMEM Score c
  PGRP    = Process Group   ENVIRON = Environment v
  • P - to sort the process list by cpu usage.

top - 14:53:48 up 37 days, 11:48,  1 user,  load average: 0.04, 0.02, 0.00
Tasks: 113 total,   1 running,  64 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.3 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :   933940 total,   143140 free,   117112 used,   673688 buff/cache
KiB Swap:        0 total,        0 free,        0 used.   797212 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
31375 root      20   0    9248   3596   3000 R   0.7  0.4   0:00.15 top
31030 root      20   0       0      0      0 I   0.3  0.0   0:00.70 kworker/3:1
    1 root      20   0  161124   6324   3852 S   0.0  0.7   2:11.36 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:04.35 kthreadd
    4 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/0:+
    6 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 mm_percpu_+
    7 root      20   0       0      0      0 S   0.0  0.0   0:03.62 ksoftirqd/0
    8 root      20   0       0      0      0 I   0.0  0.0   2:16.78 rcu_preempt
    9 root      20   0       0      0      0 I   0.0  0.0   0:06.39 rcu_sched
   10 root      20   0       0      0      0 I   0.0  0.0   0:00.00 rcu_bh
   11 root      rt   0       0      0      0 S   0.0  0.0   0:00.09 migration/0
   12 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/0
   13 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/1
   14 root      rt   0       0      0      0 S   0.0  0.0   0:00.10 migration/1
   15 root      20   0       0      0      0 S   0.0  0.0   1:02.31 ksoftirqd/1
   17 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/1

T' - to sort by the running time.

top - 14:54:28 up 37 days, 11:49,  1 user,  load average: 0.02, 0.02, 0.00
Tasks: 113 total,   1 running,  64 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.1 us,  0.2 sy,  0.0 ni, 99.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :   933940 total,   143108 free,   117144 used,   673688 buff/cache
KiB Swap:        0 total,        0 free,        0 used.   797180 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 1206 root      20   0   80336   1592   1228 S   0.0  0.2   6:51.88 irqbalance
   51 root      20   0       0      0      0 S   0.0  0.0   3:31.97 kswapd0
    8 root      20   0       0      0      0 I   0.0  0.0   2:16.79 rcu_preempt
    1 root      20   0  161124   6324   3852 S   0.0  0.7   2:11.36 systemd
  179 root      20   0       0      0      0 S   0.0  0.0   1:59.73 mmcqd/0
 1211 root      20   0  234960   3052   2012 S   0.0  0.3   1:24.01 accounts-d+
21786 systemd+  20   0   28012   2180   1436 S   0.0  0.2   1:23.21 systemd-ne+
   15 root      20   0       0      0      0 S   0.0  0.0   1:02.31 ksoftirqd/1
 1207 root      20   0  298464   1684    920 S   0.0  0.2   0:55.13 lxcfs
21802 root      19  -1   47484  18032  12616 S   0.0  1.9   0:45.68 systemd-jo+
 1226 root      20   0    7172   1264    964 S   0.0  0.1   0:17.61 cron
  590 root      20   0       0      0      0 S   0.0  0.0   0:14.62 jbd2/mmcbl+
 1223 root      20   0   10452   2804   2000 S   0.0  0.3   0:13.83 systemd-lo+
   25 root      20   0       0      0      0 S   0.0  0.0   0:13.55 ksoftirqd/3
 1212 message+  20   0    7116   2540   1600 S   0.0  0.3   0:12.46 dbus-daemon
PreviousVmstatNextSar

Last updated 5 years ago

Was this helpful?