【Linux】命令 - top

Posted by 西维蜀黍 on 2021-07-12, Last Modified on 2022-12-10

Meaning

  • PID: Shows task’s unique process id.

  • PR: Stands for priority of the task.

  • NI: Represents a Nice Value of task. A Negative nice value implies higher priority, and positive Nice value means lower priority.

  • VIRT, RES, SHR and %MEM: These three fields are related with to memory consumption of the processes.

    • “VIRT”: Virtual Memory Size (KiB)
      • The total amount of virtual memory used by the task. It includes all code, data and shared libraries plus pages that have been swapped out and pages that have been mapped but not used.
    • “RES” is the physical memory consumed by the process in RAM
    • “%MEM”: A task’s currently resident share of available physical memory.
    • SHR: Represents the Shared Memory size (kb) used by a task.
  • TIME+: CPU Time, the same as ‘TIME’, but reflecting more granularity through hundredths of a second.

  • COMMAND: The COMMAND column shows the name of the processes.

Usage

  • Shows Absolute Path of Processes: Press ‘c‘ option in running top command, it will display absolute path of running process
  • Sort by CPU Utilisation: Press (Shift+P) to sort processes as per CPU utilization.
# Start top, all options are available in the interface:
$ top

# Start top sorting processes by internal memory size (default order - process ID):
$ top -o mem

# Start top sorting processes first by CPU, then by running time:
$ top -o cpu -O time

# Display Specific User Process
$ top -u [paras]

Reference