Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1

See http://hisham.hm/htop/ for more details.


Displaying Free and Used Memory with free


Although top includes some memory information, the free utility displays
the amount of free and used memory in the system, in kilobytes. (The -m
switch causes it to display in megabytes.) On one system, the output looks
like this:


Click here to view code image
matthew@seymour:~$ free
total used free shared buffers
cached
Mem: 4055680 3327764 727916 0 280944
2097568
−/+ buffers/cache: 949252 3106428
Swap: 8787512 0 8787512


This output describes a machine with 4GB of RAM memory and a swap
partition of 8GB. Note that none of the swap is being used and that the
machine is not heavily loaded. Linux is very good at memory management
and “grabs” all the memory it can in anticipation of future work.


TIP
A useful trick is to employ the watch command, which repeatedly reruns
a command every two seconds by default. If you use the following, you can
see the output of the free command updated every two seconds:

Click here to view code image
matthew@seymour:~$ watch free


Use Ctrl+C  to  quit.

Another useful system-monitoring tool is vmstat (virtual memory
statistics). This command reports on processes, memory, I/O, and CPU,
typically providing an average since the last reboot; or you can make it report
usage for a current period by telling it the time interval, in seconds, and the
number of iterations you desire, like this:


Click here to view code image
matthew@seymour:~$ vmstat 5 10


This causes vmstat to run every five seconds for 10 iterations.


Use the uptime command to see how long it has been since the last reboot
and to get an idea of what the load average has been; higher numbers mean

Free download pdf