Categories
Linux Tutorial Series

Linux Tutorial Series – 113 – Review – revisiting top’s columns

Here is the video version, if you prefer it:

Let’s look at the output produced by top and explain what does it all mean:

mislav@mislavovo-racunalo:~/Linux_folder$ top

top - 13:15:58 up 101 days, 19:37, 1 user, load average: 0.44, 0.42, 0.44

Tasks: 241 total, 1 running, 239 sleeping, 0 stopped, 1 zombie

%Cpu(s): 0.2 us, 0.1 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st

MiB Mem : 7853.8 total, 127.8 free, 4300.2 used, 3425.8 buff/cache

MiB Swap: 8066.0 total, 6694.0 free, 1372.0 used. 2891.4 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

8770 mislav 20 0 3002016 320192 111444 S 1.0 4.0 5:46.85 Web Content

8357 mislav 20 0 3524552 369556 151704 S 0.3 4.6 5:26.81 firefox-esr

14417 mislav 20 0 4222052 321880 168376 S 0.3 4.0 0:31.67 anki

...

  • First we have some information about current time, how long my machine has been running and how many users are logged in (Shotts, 2019)⁠
  • load average – how many processes is your computer executing in the last minute, last 5 minutes, last 15 minutes
  • Tasks – how many tasks are there on the computer – 1 is running (meaning being actively executed), 239 are sleeping (meaning waiting for something to happen (such as data from a device) to resume their execution), 0 stopped (meaning no processes whose execution was paused manually) and 1 zombie process (zombie process is a process whose parent process doesn’t exist anymore)
  • %Cpu(s) tells us what percentage of the CPU is being used on what kinds of processes: us is for user processes, sy is for system (kernel) processes, ni is for nice (low-priority) processes, id is for the percentage of the CPU that is idle, wa is for percentage of the CPU waiting for some input/output tasks, hi is the time spent processing hardware interrupts, si is the time processing software interrupts and st is relevant to virtual environments – if you don’t know what virtual environments are, that needn’t concern you (“Linux ‘top’ command: What are us, sy, ni, id, wa, hi, si and st (for CPU usage)?,” n.d.)⁠
  • MiB Mem and MiB swap tell you how much RAM and how much swap space is being used (measured in mebibytes (“Mebibyte,” n.d.)⁠)

Let’s now look at the columns available for each process: (“A Guide to the Linux ‘Top’ Command,” n.d.)⁠

  • PID – proces ID
  • USER – user who owns the process
  • PR – process priority
  • NI – niceness (nice value) of a process
  • VIRT – total amount of memory consumed by the process (permanent storage device + RAM – the basic idea is that if the operating system runs out of RAM, it can use some memory available on the permanent storage device in addition to the RAM; this concept is called virtual memory – look it up on Google if you are interested)
  • RES – memory consumed by the process in RAM
  • SHR – amount of memory shared with other processes (processes can share memory)
  • S – process state (is the process running, is it sleeping, …)
  • %CPU – how much CPU is the process using (in percentages)
  • %MEM – how much memory is the process using (in percentages)
  • TIME+ – total time used by the process since it started
  • COMMAND – the name of the process

Hope you understand the output of top in detail now and hope you refreshed your memory!

References

A Guide to the Linux “Top” Command. (n.d.). Retrieved February 19, 2020, from https://www.booleanworld.com/guide-linux-top-command/#Understanding_top8217s_interface_the_task_area

Linux “top” command: What are us, sy, ni, id, wa, hi, si and st (for CPU usage)? (n.d.). Retrieved February 19, 2020, from https://unix.stackexchange.com/questions/18918/linux-top-command-what-are-us-sy-ni-id-wa-hi-si-and-st-for-cpu-usage

Mebibyte. (n.d.). Retrieved February 19, 2020, from https://en.wikipedia.org/wiki/Mebibyte

Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Pages 137-139

Categories
Linux Tutorial Series

Linux Tutorial Series – 100 – The top command

Here is the video version, if you prefer it:

To view processes dynamically, use top. (Shotts, 2019) It displays which processes are using up your resources the most – the ones using the most resources is always at the top of the list.

An example:

mislav@mislavovo-racunalo:~$ top

top - 20:34:02 up 96 days, 2:55, 1 user, load average: 1.11, 0.79, 0.62

Tasks: 237 total, 1 running, 235 sleeping, 0 stopped, 1 zombie

%Cpu(s): 5.2 us, 0.7 sy, 0.0 ni, 93.3 id, 0.0 wa, 0.0 hi, 0.7 si, 0.0 st

MiB Mem : 7853.8 total, 985.1 free, 4153.0 used, 2715.7 buff/cache

MiB Swap: 8066.0 total, 6826.2 free, 1239.8 used. 3013.4 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

1145 mislav 20 0 874948 216852 29184 S 33.3 2.7 89:30.61 gedit

6729 mislav 20 0 4991000 460424 110440 S 13.3 5.7 1631:07 gnome-she+

15544 mislav 20 0 11276 3644 3060 R 6.7 0.0 0:00.01 top

...

⁠I won’t go into the details of the column names or the meaning of each element of the summary statistics here. I will leave that for review, when we cover all of the relevant concepts. For now, just remember that top is a command that displays the processes with the most resource-intensive processes closer to the top of the process list.

Hope you learned something useful!

References

Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Pages 137-139